Arduino freezing after moving from Mega to Nano.

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.