Created
March 6, 2016 19:07
-
-
Save halldorel/c9659007cf04191fcdb1 to your computer and use it in GitHub Desktop.
Arduino passthrough serial
This file contains hidden or 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
#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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Was using this to sleep at regular intervals, because the serial buffer on the receiving end had problems with the dataflow