Created
December 6, 2015 00:46
-
-
Save ocihangir/e6deb73404bbd10fd6fc to your computer and use it in GitHub Desktop.
This code converts Arduino Leonardo into a USB to UART converter
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
/* | |
* This code converts Arduino Leonardo into a USB to UART converter | |
*/ | |
int incomingByte = 0; | |
void setup() { | |
// initialize serial: | |
Serial.begin(9600); | |
while (!Serial) { | |
; // wait for serial port to connect. Needed for Leonardo only | |
} | |
Serial1.begin(9600); | |
} | |
void loop() { | |
if (Serial1.available() > 0) | |
{ | |
incomingByte = Serial1.read(); | |
Serial.write(incomingByte); | |
} | |
if (Serial.available() > 0) | |
{ | |
incomingByte = Serial.read(); | |
Serial1.write(incomingByte); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment