Minor refactor while failing to grok serial readline

This commit is contained in:
Dan Buch 2013-12-29 16:49:37 -05:00
parent 4e887413cb
commit 3c909e79e9

View File

@ -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();
}