Skip to content

Instantly share code, notes, and snippets.

@ocihangir
Created December 6, 2015 00:46
Show Gist options
  • Save ocihangir/e6deb73404bbd10fd6fc to your computer and use it in GitHub Desktop.
Save ocihangir/e6deb73404bbd10fd6fc to your computer and use it in GitHub Desktop.
This code converts Arduino Leonardo into a USB to UART converter
/*
* 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