Using Serial To Control An LED

I am trying to control an led with serial commands... I want to type "on" and "off" to control the led...

Here is the code I stated to write:

int ledPin = 13;

void setup()
  pinMode(ledPin, OUTPUT);

void loop()


please help! i tried, and it didnt work!

You haven’t written anything yet! How can we help you?

Also, did you realise there is an example built into the Arduino IDE which does this? File → Examples → Communication → PhysicalPixel

It uses “H” and “L” to turn it on/off, but I’m sure you can adapt it…

You might take a look at Bitlash, which you will find at at -- Bitlash is a serial interpreter which runs entirely on Arduino, and it supports "macros" which are stored sequences of operations.

Here is how you might define on and off for your requirements:

> startup:="pinmode(13,1)"
> on:="d13=1"
> off:="d13=0"

Then you can say:

> on


> off

And the pin D13 will turn on and off, controlling your LED.

Happy hacking,