My RFID doesn't work with Arduino Mega 2560

I tried many tutorials, but they didn't help. The strange thing is that the same RFID with the same code with changed SS pin works correctly on Arduino Uno board.

Here is how i connect RFID:

3.3v - 3.3v
RST - digital 9
GND - GND
IRQ - Not connected
MISO - digital 50
MOSI - digital 51
SCK - digital 52
SDA/SS - digital 53

And here is the code I use:

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 53
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup()
{
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
}
void loop()
{
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
content.toUpperCase();
if (content.substring(1) == "97 CE 18 D9") {
Serial.println("Card 1");
}
if (content.substring(1) == "F7 8A 94 C9"){
Serial.println("Card 2");
}
delay(500);
}

Please write a solution if you know it

Your post was MOVED to its current location as it is more suitable.

Please follow the advice given in the link below when posting code. Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.