I found this code from
http://www.suffix.be/blog/send-data-to-arduinoint ledPin = 13;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
char value = Serial.read();
if (value == '1') {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
Serial.println(value);
}
delay(1000);
}
It turns on the onboard LED when you type '1' in the serial monitor, and off when you type anything else.
However, the LED turns off on its own since the serial monitor returns to a default value immediately.
Does anybody know a way to make the LED stay on until you type something else in?