29.04.2015
The skatch start the serial monitor and wait until the other MCU is connected, than is possible to write text like a chat./* Fab Academy 2015 Networking communication Gianluca Pugliese Pierluigi De Palo Chat Program between 2 satshakit The circuit: * RX is digital pin 10 (connect to TX of other device) * TX is digital pin 11 (connect to RX of other device) based on SoftwareSerial */ #include <SoftwareSerial.h> SoftwareSerial chat(10, 11); // RX, TX int text; void setup() { // open hardware serial, TX = 1, RX = 0 Serial.begin(9600); Serial.println("Fab chat is starting..."); // set the baudrate chat.begin(9600); delay(1000); // delay 1s to stabilize serial ports chat.println("connected! start to chat"); } void loop() { if (chat.available()) Serial.write(chat.read()); if (Serial.available()) { Serial.print("Gianlu: "); chat.write("Gianlu: "); while (Serial.available()) { text = Serial.read(); chat.write(text); Serial.write(text); } chat.println(); Serial.println(); } }