a software serial sketch for Arduino ProMini units to talk to each othe?

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.

Yes, each promini needs a sketch uploaded.
You could have each one add on a sender ID that you read from 2 input pins that are connected to Gnd, or pulled high internally, so the extra info could be 00-01-10-11.

thank you; could you be more specific? how would one incorporate this piece of ID? is there specific wiring needed?
also, what happens to the pin assignments if i want to change the roles of the units? for instance, if i want to exchange the first and second arduinos (change positions), then the pin modes I have set would be wrong (i guess very much obviously).
thanks.
Karim.