Go Down

Topic: Using Serial To Control An LED (Read 602 times) previous topic - next topic

Jeremy1998

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:
Code: [Select]
int ledPin = 13;

void setup()
{
 pinMode(ledPin, OUTPUT);
 Serial.begin(9600);
}

void loop()
{

}

Jeremy1998

please help! i tried, and it didnt work!

trialex

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...

billroy

You might take a look at Bitlash, which you will find at at http://bitlash.net -- 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:

Code: [Select]

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


Then you can say:
Code: [Select]

> on

or
Code: [Select]

> off


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

Happy hacking,

-br
http://bitlash.net
http://entropymouse.com

Go Up