kikidog
1
I can't seem to figure out how to code an array that has the following strings...
char mySerial[] = {"mySerial0", "mySerial1", "mySerial2"};
then use the mySerial[] array to do the following:
void setup()
{
mySerial[1].begin(baudRate); // Set Serial1 communication at 9600bps
mySerial[2].begin(baudRate); // Set Serial2 communication at 9600bps
...
}
You simply can't do that....
Regards,
Ray L.
Deja Vu anyone? I smell a homework assignment
kikidog
5
kikidog:
I can't seem to figure out how to code an array that has the following strings...
char mySerial[] = {"mySerial0", "mySerial1", "mySerial2"};
then use the mySerial[] array to do the following:
void setup()
{
mySerial[1].begin(baudRate); // Set Serial1 communication at 9600bps
mySerial[2].begin(baudRate); // Set Serial2 communication at 9600bps
...
}
Well I did finally figure this out...I will include it here for other to use...
SoftwareSerial mySerial1 = SoftwareSerial(rx[0], tx[0]);
SoftwareSerial mySerial2 = SoftwareSerial(rx[1], tx[1]);
SoftwareSerial mySerial3 = SoftwareSerial(rx[2], tx[2]);
SoftwareSerial mySerial4 = SoftwareSerial(rx[3], tx[3]);
SoftwareSerial mySerial[4] = {mySerial1, mySerial2, mySerial3, mySerial4};
Now mySerial[x] can be used as an array...who wudda thunk??? 
DrAzzy
7
You know, using 4 software serial instances at once is not such a great idea, in general...
- only one software serial instance can receive at any given time.
- transmitting or receiving on software serial takes the Arduino's full attention - it can't do anything else during that time.