#include // declare second serial port with pin 10 and 11 for RX and TX pin SoftwareSerial serial2(10, 11); // RX, TX void setup() { Serial.begin(9600); // start serial port between self and computer with 9600 baud rate serial2.begin(4800); // start software serial with other board with 4800 baud rate } // string to hold current message from the computer String current_msg = ""; void loop() { // loop while there's data from other board while (serial2.available() > 0) { // send received data to computer char c = serial2.read(); Serial.write(c); } // read data input by the computer while (Serial.available() > 0) { char c = Serial.read(); if (c == '\n') { // newline means we've read the whole message // show what we've entered on the serial monitor Serial.print("me: "); Serial.println(current_msg); current_msg = ""; // reset the string } else { current_msg += c; // append the character to the string } serial2.write(c); // send the data to other board } }