Hello,
I am looking at this example code from tutorial
SoftwareSerial portOne(10, 11);
// software serial #2: RX = digital pin 8, TX = digital pin 9
// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
SoftwareSerial portTwo(8, 9);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// Start each software serial port
portOne.begin(9600);
portTwo.begin(9600);
}
is it legal to make two different baudrate like this?
portOne.begin(31250);
portTwo.begin(9600);
Because I need midi input 31250 and tx rx serial output 9600 for servo controller.
I have not testet yet because it need to write code alot before I can test it. So I will ask here.
forgoden:
SoftwareSerial portOne(10, 11);
// software serial #2: RX = digital pin 8, TX = digital pin 9
// on the Mega, use other pins instead,
}
is it legal to make two different baudrate like this?
portOne.begin(31250);
portTwo.begin(9600);
Because I need midi input 31250 and tx rx serial output 9600 for servo controller.
I would seriously question any tutorial that talks about using software serial on a Mega, but maybe you are using a Uno etc. anyway, and yes, it is OK to have two ports at different speeds.
All you need is to ensure that whatever is at the other end is set to match. 31250 seems a pretty funny speed. Note that Software serial is only good for reliable operation up to 38400. You might consider using the midi device on hardware serial, rather than stretch the friendship.
There are several software serial libraries available. The one you have chosen is the worst.
See https://arduino.stackexchange.com/questions/34126/whats-the-difference-between-all-the-software-serial-libraries for a summary.
If you use a software Serial only to TX you better set the RX pin to -1
This will save you a pin.
Don't know if that works on all SW serial libs,
Ok thank you all, I will try