Invoking multiple instances of SoftwareSerial in an array

I am trying to use an Arduino Mega as a multiplexer for serial communication between PC and multiple 'slave' Arduinos.

For this I need 12 instances of SoftwareSerial running. I can create them in the normal fashion:

SoftwareSerial Serial01 (10, 8);
SoftwareSerial Serial02 (11, 9);
.....

But it would be very helpful if i could address them as an array. Something like

SoftwareSerial MySerial[0] (10, 8);
SoftwareSerial MySerial[1] (11, 9);

But that doesn't seem to want to work. I'm not a C++ programmer and things that go beyond what can be found in the examples are a beyond my current grasp. Any hints would be appreciated.

You can create an array of SoftwareSerial instances, but, before getting into how, are you aware that you can only have one instance listening at a time? Whatever comes in on the other 11 pins will be lost.

I'm aware of the problem with just one instance listening at a time. The project is using a simple challenge-response protocol, so I won't have any problems with slaves just starting to talk.

#include "SoftwareSerial.h"

SoftwareSerial Stuff[4] = {SoftwareSerial(2,3),
                           SoftwareSerial(4,5),
                           SoftwareSerial(6,7),
                           SoftwareSerial(7,8)};
                          
void setup() {}
void loop() {}

Don't forget that only some pins can be used. I don't think that there are 24 of them that can be used.

Great - that seems to work.
And the pin limitation is on the RX pin only and there's 16 available for that, so we should be OK.

Thanks!

PaulS:

#include "SoftwareSerial.h"

SoftwareSerial Stuff[4] = {SoftwareSerial(2,3),
                          SoftwareSerial(4,5),
                          SoftwareSerial(6,7),
                          SoftwareSerial(7,8)};
                         
void setup() {}
void loop() {}




Don't forget that only some pins can be used. I don't think that there are 24 of them that can be used.

Sorry mate, I know it has passed time from this post, but do you think is it possible to do the same for example in SevSeg.h library?
here is the link:
https://docs.google.com/file/d/0Bwrp4uluZCpNdE9oWTY0M3BncTA/edit

My purpose is to switch between 8 long placed displays (no simultaneous displays, only once at time), and should be great to handle this with a loop like:

#include <SevSeg.h>
SevSeg sevseg[8]={sevseg1, sevseg2, sevseg3......sevseg8};
void setup(){
for(byte i=0;i<8;i++){
sevseg[i].begin(1,d4[i],d3[i],d2[i],d1[i],seg[1],seg[2],seg[3],seg[3],seg[4],seg[5],seg[6],seg[7],seg[8]); //in case of d4 d3 d2 d1 and seg arrays declared
sevseg[i].Brightness(80);
}
}
void loop (){

//incase of some multiple incoming bytes
for(byte i=0;i<8;i++){
seveg[i].NewNum(int(incomingByte[i]),0);
sevseg[i].PrintOut();
}
}

That would be easy to handle, no?
Thanks in advance

I am not sure,
I have been reading other libraries like LED, and I am going to try this:

SevSeg sevseg[8]={SevSeg(),SevSeg(),SevSeg(),SevSeg(),SevSeg(),SevSeg(),SevSeg(),SevSeg()};

hope there won't be collision...
At least compilator doesn't complain......at the moment XD