LED switch exercise

This commit is contained in:
Dan Buch 2013-12-29 15:12:21 -05:00
parent 06abc7febd
commit 9481259966
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,29 @@
const unsigned int LED_PIN = 13;
const unsigned int BAUD_RATE = 9600;
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(BAUD_RATE);
}
void loop() {
if (Serial.available() <= 0) {
return;
}
int command = Serial.read();
switch (command) {
case '1':
digitalWrite(LED_PIN, HIGH);
Serial.println("LED on");
break;
case '2':
digitalWrite(LED_PIN, LOW);
Serial.println("LED off");
break;
default:
Serial.print("Unknown command: ");
Serial.println(command);
}
}

1
arduino/LEDSwitch/Makefile Symbolic link
View File

@ -0,0 +1 @@
../arduino.mk