UNO vs MEGA Rx/Tx Pins

Im working with a SIM900 module bought from SainSmart on a MEGA.

I somehow connected it and it magically "just works"! My sketch that simply sends out and SMS. :-)

Here is my question: Ok, the UNO is a bit different because it only has a dedicated Rx & Tx pin. MEGA has a bunch more. But even so, is there no need to specify the pins you are using for Rx & Tx when using the MEGA?

How does the UNO/MEGA know where to look for outgoing/incoming data?

Is it because those are designated Rx/Tx hardware pins that they don't need software/code specification?

Is it because those are designated Rx/Tx hardware pins that they don’t need software/code specification?

The Serial object is an instance of the HardwareSerial class. That class knows about the hardware - both the Mega and the Uno and the Due and all the other supported hardware.

Right. But if I wanted to use different pins I would need to define them in code using software serial, right?

No, just use Serial, Serial1, Serial2, Serial3 for the 4 hardware serial ports.

Right, which correspond to Tx/Rx0, 1, 2 & 3. Those are hardware serial ports.

But I could still use SoftwareSerial to define another set of ports as Rx/Tx? Like is done when working with Arduino UNO and Bluetooth modules.

But I could still use SoftwareSerial to define another set of ports as Rx/Tx? Like is done when working with Arduino UNO and Bluetooth modules.

On some pins. But, you really need to consider whether 5 or more serial devices connected to a Mega makes sense.

PaulS

No, I wouldn't. I was just trying to see if I understood the idea of hw serial ports vs software ones.

Well, hardware is hardware - there are UARTs in the Mega with built-in clock generation for sampling the bits to support the various data rates. Software serial fakes that, and uses pins that support PCINT (so not all Mega pins) as part of the process. Sending & Receiving a data byte is not handled independently by the hardware, but instead requires numerous software commands to make it happen. That's why the data rate for software serial is much slower, while the hardware can run at 115200, 230400, and up to 1M.