Check for ESC key never reached in de code below.
Using TerraTerm to send key strokes to the Arduino are showing me that the ESC HEX-code =0x27 but this key is never reconized. Why not??
#include <Arduino.h>
#include <Streaming.h> /* http://arduiniana.org/libraries/streaming/ */
#define KEY_ESC 0x1B
boolean recvCommand = false;
void setup() {
Serial.begin(9600);
Serial.println("Enter Command: ");
Serial << "BIN\tOCT\tDEC\tHEX" << endl;
}
void loop() {
char c = Serial.read(); // note read() returns an int, char c = converts it to a char
if (c != -1) { // read() return -1 if there is nothing to be read.
// got a char show it
Serial.print(c, BIN);
Serial.print("\t");
Serial.print(c, OCT);
Serial.print("\t");
Serial.print(c, DEC);
Serial.print("\t");
Serial.print(c, HEX);
Serial.print("\t");
Serial.println(c);
recvCommand = true;
}
if (recvCommand == true) {
Serial.println("Execute command");
recvCommand = false;
} else if (recvCommand == true && c == KEY_ESC) {
Serial.println("Execute num-key");
recvCommand = false;
}
}