Skip to content

Instantly share code, notes, and snippets.

@volca
Last active December 21, 2015 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volca/6333732 to your computer and use it in GitHub Desktop.
Save volca/6333732 to your computer and use it in GitHub Desktop.
soft serial test for arduino leonardo
#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());
}
}
@volca
Copy link
Author

volca commented Dec 15, 2014

For BlueDuino, the rx, tx is pin 11, 12.

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