Hello, I want to control a LED, set it to either HIGH or LOW, by sending values through the serial monitor.
Here is one example of something similar, but I dont know what the Arduino code he uses looks like:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=37469
I tried with this code, but it does not work:
const int ledPin = 9;
const int ledPin2 = 10;
void setup(){
Serial.begin(9600);
}
void loop () {
if (Serial.available()>0) {
//int d = 0;
int d= Serial.read();
if ( d == 10 )
{
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin2, HIGH);
}
else if ( d == 20 )
{
digitalWrite(ledPin, LOW);
digitalWrite(ledPin2, LOW);
}
}
}
I simply plugg the Arduino into my computer, open the serial monitor and put "1" into the send text field and send it. RX LED on the Arduino flashes when I do this, but the LED does not go on. Anybody know what im doing wrong here?