I have a simple sketch working on arduino Uno and Nano sending data using an XBee. However, if I run the project on an Arduino Mega it does not work.

What differences between Uno/Nano and the Mega could be causing issues?

Connection: I just connect 3.3V->3.3V, Gnd->Gnd, and have tried various ports for DIN and DOUT (normally pins 2/4, but have tried A0/A1, 22/23 etc..).

Sketch: pastebin

Have brought a second Mega in case of hardware faults, but the problem persists. Have stripped anything which might be tying up a timer. Am choosing the right board type in the arduino IDE.

  • Update: changing the sketch to use HardwareSerial works, but I'd like to understand what's different between the devices here.
    – Jethro
    Commented Jan 20, 2019 at 14:43

1 Answer 1


Not all arduino Mega pins support 'change interrupts', which is needed for Software Serial. Only the following can be used for RX:

10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

  • Mega has 4 hardware serial ports, no excuse to be using software serial.
    – CrossRoads
    Commented Oct 17, 2019 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.