Making the serial echo thing a smidge more interesting
This commit is contained in:
parent
3a37663fed
commit
3c7e37f7a3
@ -1,13 +1,28 @@
|
||||
const unsigned int BAUD_RATE = 9600;
|
||||
unsigned int keys = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(BAUD_RATE);
|
||||
Serial.begin(BAUD_RATE);
|
||||
Serial.print("> ");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.available() <= 0) {
|
||||
return;
|
||||
}
|
||||
if (Serial.available() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.write(Serial.read());
|
||||
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("> ");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user