Minor refactor while failing to grok serial readline
This commit is contained in:
parent
4e887413cb
commit
3c909e79e9
@ -21,19 +21,10 @@ void ledBlink() {
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
Serial.begin(BAUD_RATE);
|
||||
}
|
||||
void handleInput() {
|
||||
int c = Serial.read();
|
||||
|
||||
void loop() {
|
||||
if (Serial.available() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int command = Serial.read();
|
||||
|
||||
switch (command) {
|
||||
switch (c) {
|
||||
case '1':
|
||||
ledOn();
|
||||
break;
|
||||
@ -45,6 +36,19 @@ void loop() {
|
||||
break;
|
||||
default:
|
||||
Serial.print("Unknown command: ");
|
||||
Serial.println(command);
|
||||
Serial.println(c);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
Serial.begin(BAUD_RATE);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.available() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleInput();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user