box-o-sand/oldstuff/arduino/misc/SerialEcho/SerialEcho.ino
2015-06-22 13:15:42 -05:00

29 lines
492 B
C++

const unsigned int BAUD_RATE = 9600;
unsigned int keys = 0;
void setup() {
Serial.begin(BAUD_RATE);
Serial.print("> ");
}
void loop() {
if (Serial.available() <= 0) {
return;
}
Serial.write(Serial.read());
keys++;
if (keys == 100) {
Serial.println("\nKABOOM!!!");
keys = 0;
Serial.print("> ");
return;
}
Serial.println("");
Serial.print(keys);
Serial.println(" keys pressed");
Serial.print("> ");
}