Slight note:
I believe you can call the functions like setRX before or after the Serial2.begin...
However if you do it in the order:
Code:
Serial2.begin(9600);
Serial2.setRX (26);
Serial2.setTX (31);
The Serial2.begin will first setup the default pins to be in Serial mode, and then the two set functions will then set the default pins back to disabled and then set the new pins to Serial mode.
If you call it in the order:
Code:
Serial2.setRX (26);
Serial2.setTX (31);
Serial2.begin(9600);
The set functions will just remember which pin you selected and then when you call begin those pins will be setup in Serial mode and the default pins will not be touched.
But both ways should work