Hardware Reference
In-Depth Information
Card_reader() function
This function is to control, read and write data on RC522 RFID card. At first, it store
FF code in key variable because usually the default password for these cards is FF .
MFRC522::MIFARE_Key key;
for (byte i = 0; i < 6; i++)
key.keyByte[i] = 0xFF;
Then, it checks if there is a card on card reader device or not. If there is no card, exit from
this function
if ( ! mfrc522.PICC_IsNewCardPresent() )
return;
But, if there are some cards on the card reader a card is selected.
if ( ! mfrc522.PICC_ReadCardSerial() )
return;
The following variable defined in the card memeory.
byte sector = 1;
byte valueBlockA = 4;
byte valueBlockB = 5;
byte valueBlockC = 6;
byte trailerBlock = 7;
Then a connection between the card and card reader should be made. It gives the password
( keyA ) to the card. If the password is incorrect or the card isn't valid, it logs out from the
card and then the red LED is turned on and three beeps are sounded and at the end, it exits
the card reader.
status =
mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A,
trailerBlock, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK)
Search WWH ::




Custom Search