Serial Experiments

After completing the Serial project, test yourself by trying these experiments.

1 Making the connections
  • Label one Arduino the master sender and the other Arduino the slave receiver.
  • Connect pin 7 on the sender Arduino to pin 8 on the receiver Arduino.
  • Connect pin 6 on the sender Arduino to pin 9 on the receiver Arduino.
  • Connect one Arduino to one computer with the regular USB cable.
  • Connect the other Arduino to a second computer with the regular USB cable.
Serial connection between two Arduinos
2 Type in and upload this sender program to the MASTER SENDER Arduino
// This is the Serial MASTER SENDER
// Connect pin 7 on this Arduino to pin 8 on the receiver Arduino
// Connect pin 6 on this Arduino to pin 9 on the receiver Arduino

#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7); // RX, TX

void setup() {
  Serial.begin(9600); // hardware serial for output to monitor
  mySerial.begin(9600); // begin software serial
  Serial.println("Master Sender");
}

void loop() {
  while (Serial.available()) {
    char ch = Serial.read();
    mySerial.write(ch);
  }

  while (mySerial.available()) {
    char ch = mySerial.read();
    Serial.print(ch);
  }
}
3 Type in and upload this receiver program to the SLAVE RECEIVER Arduino
// This is the Serial SLAVE RECEIVER
// Connect pin 8 on this Arduino to pin 7 on the sender Arduino
// Connect pin 9 on this Arduino to pin 6 on the sender Arduino

#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9); // RX, TX

void setup() {
  Serial.begin(9600); // hardware serial for output to monitor
  mySerial.begin(9600); // begin software serial
  Serial.println("Slave Receiver");
}

void loop() {
  while (Serial.available()) {
    char ch = Serial.read();
    mySerial.write(ch);
  }

  while (mySerial.available()) {
    char ch = mySerial.read();
    Serial.print(ch);
  }
}
4 Open up the serial monitor for both the sender and the receiver. Set the baud speed on both to 9600. Type some characters in on one monitor and you should see the characters displayed in the other monitor.