2016-04-11 21:06:05 +00:00
|
|
|
volatile char cmd_char = 'z';
|
|
|
|
|
2018-01-10 04:24:09 +00:00
|
|
|
const char cmd_id = 'i';
|
|
|
|
|
2016-04-11 21:06:05 +00:00
|
|
|
void setup() {
|
|
|
|
Serial.begin(57600);
|
|
|
|
Serial.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
if (Serial.available()) {
|
|
|
|
/* read the most recent byte */
|
|
|
|
cmd_char = (char)Serial.read();
|
|
|
|
}
|
|
|
|
if (cmd_char != 'z') {
|
|
|
|
cmd(cmd_char);
|
|
|
|
cmd_char = 'z';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd (char val) {
|
2018-01-10 04:24:09 +00:00
|
|
|
if (val == cmd_id) {
|
|
|
|
Serial.println(cmd_id);//End of action
|
2016-04-11 21:06:05 +00:00
|
|
|
}
|
|
|
|
}
|