Skip to content

Instantly share code, notes, and snippets.

@halldorel
Created March 6, 2016 19:07
Show Gist options
  • Save halldorel/c9659007cf04191fcdb1 to your computer and use it in GitHub Desktop.
Save halldorel/c9659007cf04191fcdb1 to your computer and use it in GitHub Desktop.
Arduino passthrough serial
#include <SoftwareSerial.h>
#define RX_PIN 9
#define TX_PIN 10
SoftwareSerial printer = SoftwareSerial(RX_PIN, TX_PIN);
void setup() {
Serial.begin(9600);
printer.begin(19200);
}
int incomingByte = 0;
int cnt = 0;
void loop() {
if(Serial.available() > 0) {
incomingByte = Serial.read();
// Forward bytes to printer
Serial.println(incomingByte, HEX);
printer.write(incomingByte);
if(printer.overflow()) {
Serial.println("SoftwareSerial buffer overflow!");
}
//Serial.println(printer.read(), HEX);
}
}
@halldorel
Copy link
Author

Was using this to sleep at regular intervals, because the serial buffer on the receiving end had problems with the dataflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment