Adding a '3' command for blinky time
This commit is contained in:
parent
9481259966
commit
4e887413cb
@ -1,6 +1,26 @@
|
||||
const unsigned int LED_PIN = 13;
|
||||
const unsigned int BAUD_RATE = 9600;
|
||||
|
||||
void ledOn() {
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
Serial.println("LED on");
|
||||
}
|
||||
|
||||
void ledOff() {
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
Serial.println("LED off");
|
||||
}
|
||||
|
||||
void ledBlink() {
|
||||
Serial.println("BLINKY TIME");
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ledOn();
|
||||
delay(100);
|
||||
ledOff();
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
Serial.begin(BAUD_RATE);
|
||||
@ -15,12 +35,13 @@ void loop() {
|
||||
|
||||
switch (command) {
|
||||
case '1':
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
Serial.println("LED on");
|
||||
ledOn();
|
||||
break;
|
||||
case '2':
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
Serial.println("LED off");
|
||||
ledOff();
|
||||
break;
|
||||
case '3':
|
||||
ledBlink();
|
||||
break;
|
||||
default:
|
||||
Serial.print("Unknown command: ");
|
||||
|
Loading…
Reference in New Issue
Block a user