Arduino freezing after moving from Mega to Nano.

Hey guys, I just finished developing an RFID scanner on an Arduino Mega to use as a motorcycle ignition system and it all worked fine on my Mega 2560 I purchased a Nano today to use as the main device.

I only changed 2 parts of my code. I remove some LED's as the production part won't have them but left the LED part of the code in (There's just nothing connected to those pinouts) and some of the digital pins to suit the nano (those that exist on the Mega but not on the Nano).

Now whenever I scan an RFID chip the Arduino just freezes the LED on pinout 13 lights up permanently and if I restart it it does the same thing again.

Code is a bit long to fit here but I made a github repo for it. I'm hoping someone can help I'm stumped...

Does SPI use the same pins on the Mega as on the Nano ?

Did you get any compiler warnings about the size of your code or memory usage ?

This, for example, would be fine:

Sketch uses 1834 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 207 bytes (10%) of dynamic memory, leaving 1841 bytes for local variables. Maximum is 2048 bytes.

UKHeliBob:
Does SPI use the same pins on the Mega as on the Nano ?

No different ones,


MFRC522 Arduino Arduino Arduino Arduino Arduino
Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro
Signal Pin Pin Pin Pin Pin Pin

RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
SPI SS SDA(SS) 10 53 D10 10 10
SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15

6v6gt:
Did you get any compiler warnings about the size of your code or memory usage ?

This, for example, would be fine:

Sketch uses 1834 bytes (5%) of program storage space. Maximum is 32256 bytes.

Global variables use 207 bytes (10%) of dynamic memory, leaving 1841 bytes for local variables. Maximum is 2048 bytes.

None, this was the output from the compiler + upload

Sketch uses 9588 bytes (31%) of program storage space. Maximum is 30720 bytes.
Global variables use 262 bytes (12%) of dynamic memory, leaving 1786 bytes for local variables. Maximum is 2048 bytes.

SOLVED!

I specified Pins 3 and 2 as LED outputs (I believe Pin 3 is an interupt??) I swapped them to A1-3 and it solved my problem. All working as it should now!

Thanks for your help guys!

I specified Pins 3 and 2 as LED outputs (I believe Pin 3 is an interupt??) I swapped them to A1-3 and it solved my problem.

I do not see why that would solve the problem. Can anyone explain ?