box-o-sand/oldstuff/arduino/misc/SerialEcho/SerialEcho.ino

29 lines
492 B
Arduino
Raw Normal View History

2013-12-29 23:49:27 +00:00
const unsigned int BAUD_RATE = 9600;
unsigned int keys = 0;
2013-12-29 23:49:27 +00:00
void setup() {
Serial.begin(BAUD_RATE);
Serial.print("> ");
2013-12-29 23:49:27 +00:00
}
void loop() {
if (Serial.available() <= 0) {
return;
}
2013-12-29 23:49:27 +00:00
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("> ");
2013-12-29 23:49:27 +00:00
}