Hello,
I am trying to make a few Arduino ProMini units to talk to each other over serial communication. You may have seen my previous posts where I explained why there needs to be multiple of these units to talk to one another at (virtually) the same time. As there are not sufficient hardware serial ports, I need to create soft serial ports out of the available pins. I wanted to code it first, but found a sketch about it and tried to modify that:
#include <SoftwareSerial.h>
SoftwareSerial portOne(2, 3);
SoftwareSerial portTwo(4, 5);
void setup()
{
// Open serial communications and wait for port to open:
pinMode(2, INPUT);
pinMode(3, OUTPUT);
pinMode(4, INPUT);
pinMode(5, OUTPUT);
Serial.begin(9600);
portOne.begin(9600);
portTwo.begin(9600);
}
void loop()
{
// By default, the last intialized port is listening.
// when you want to listen on a port, explicitly select it:
portTwo.listen();
Serial.print("Data from port one:");
// while there is data coming in, read it
// and send to the hardware serial port:
while (portTwo.available() > 0) {
char inByte = portTwo.read();
Serial.write(inByte);
}
Serial.println();
portOne.listen();
Serial.print("Data from port two:");
while (portOne.available() > 0) {
char inByte = portOne.read();
Serial.write(inByte);
}
Serial.println();
}
this sketch above was compiled and uploaded successfully. However when I upload the sketch, do I need to upload it to every single unit? Should I change any parts of it? How would I test that the communication is working?
Attached is a schematic for your reference.
Thank you,
Karim.