Last active
December 21, 2015 16:28
-
-
Save volca/6333732 to your computer and use it in GitHub Desktop.
soft serial test for arduino leonardo
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
#include <SoftwareSerial.h> | |
SoftwareSerial mySerial(11, 12); //RX,TX | |
String tmp; | |
void setup() { | |
Serial.begin(9600); | |
mySerial.begin(9600); | |
while (!Serial) { | |
; // wait for serial port to connect. Needed for Leonardo only | |
} | |
Serial.println("hello!"); | |
}; | |
void loop() { | |
while (mySerial.available() > 0) { | |
tmp += char(mySerial.read()); | |
delay(2); | |
} | |
if(tmp.length() > 0) { | |
Serial.println(tmp); | |
tmp = ""; | |
} | |
if (Serial.available()) { | |
mySerial.write(Serial.read()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For BlueDuino, the rx, tx is pin 11, 12.