کد مقایسه آیدی کارت :
کد:
#include <SPI.h>
#include <MFRC522.h>




MFRC522 mfrc522(10, 9);


byte Cardid[4] = {75, 79, 63, 76};
byte readCard[4];


boolean match = false;


void setup() {
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
}


void loop() {
  if ( mfrc522.PICC_IsNewCardPresent())
  {
    if ( mfrc522.PICC_ReadCardSerial())
    {
      Serial.print("Card UID:");
      for (byte i = 0; i < mfrc522.uid.size; i++) {
        readCard[i] = mfrc522.uid.uidByte[i];
        Serial.print(readCard[i], HEX);
      }
      checkTwo(readCard, Cardid);
      Serial.println();
      mfrc522.PICC_HaltA();
    }
  }
}


void checkTwo ( byte a[], byte b[] ) {
  if ( a[0] != NULL )       // Make sure there is something in the array first
    match = true;       // Assume they match at first
  for ( int k = 0; k < 4; k++ ) {   // Loop 4 times
    if ( a[k] != b[k] )     // IF a != b then set match = false, one fails, all fail
      match = false;
  }
  if ( match ) {      // Check to see if if match is still true
    Serial.print("Match");
  }
  else  {
    Serial.print("Not Match");
  }
}