Skip to content

Commit

Permalink
Added SoftwareSerial example
Browse files Browse the repository at this point in the history
  • Loading branch information
pictux committed Oct 19, 2012
1 parent fa3b65d commit cd7b68c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/chatSoftwareSerial/chatSoftwareSerial.ino
@@ -0,0 +1,34 @@
/*
Simple Arduino Chat
Set "Both NL & CR" as line ending
*/

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX
String msg = "";
char c;

void setup()
{
Serial.begin(9600);

Serial.println("Arduino Chat");
mySerial.begin(9600);
}

void loop() // run over and over
{
if (mySerial.available()) {
c = mySerial.read();
if (c == '\n') {
Serial.println(msg);
msg = "";
} else {
msg += c;
}
}

if (Serial.available())
mySerial.write(Serial.read());
}

0 comments on commit cd7b68c

Please sign in to comment.