LED switch exercise
This commit is contained in:
parent
06abc7febd
commit
9481259966
29
arduino/LEDSwitch/LEDSwitch.ino
Normal file
29
arduino/LEDSwitch/LEDSwitch.ino
Normal 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
1
arduino/LEDSwitch/Makefile
Symbolic link
@ -0,0 +1 @@
|
||||
../arduino.mk
|
Loading…
Reference in New Issue
Block a user