Created
September 18, 2014 18:51
-
-
Save Protoneer/96db95bfb87c3befe46e to your computer and use it in GitHub Desktop.
Serial Echo On Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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