Skip to content

Instantly share code, notes, and snippets.

@Protoneer
Created September 18, 2014 18:51
Show Gist options
  • Save Protoneer/96db95bfb87c3befe46e to your computer and use it in GitHub Desktop.
Save Protoneer/96db95bfb87c3befe46e to your computer and use it in GitHub Desktop.
Serial Echo On Arduino
/*
* serial_echo.pde
* -----------------
* Echoes what is sent back through the serial port.
*
* http://spacetinkerer.blogspot.com
*/
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print((char)incomingByte);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment