Skip to content

Instantly share code, notes, and snippets.

@danielwegener
Last active September 12, 2015 22:12
Show Gist options
  • Save danielwegener/c201bac5ae1c4b9a3284 to your computer and use it in GitHub Desktop.
Save danielwegener/c201bac5ae1c4b9a3284 to your computer and use it in GitHub Desktop.
Use arduino (due) as serial tunnel when your usb 2 serial cable is lost
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
Serial1.begin(9600);
blink();
blink();
blink();
}
void blink() {
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}
void loop() {
serialEvent(); //call the function
}
void serialEvent() {
while (Serial1.available()) {
int inChar = Serial1.read();
Serial.write(inChar);
}
while (Serial.available()) {
int inChar = Serial.read();
Serial1.write(inChar);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment