Compare present reading and the last reading Using RFID

Hi everyone , I need a help , am using RFID for a door and I want the code does not open the door if the last read (of the same card) is less than 10 mins, I have more than one card and tag.

#define RST_PIN 9 // Configurable, see typical pin layout above
#define SS_PIN 10 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

byte accessUID[4] = {0x79, 0x79, 0xDA, 0xB3}; //card ID
byte accessUID2[4] = {0x07, 0x97, 0x9E, 0x60}; //card ID
int motor=2;
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
Serial.println(F("Read personal data on a MIFARE PICC:")); //shows in serial that it is ready to read

pinMode(motor,OUTPUT);
void loop() {

// Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
MFRC522::MIFARE_Key key;
for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;

//some variables we need
byte block;
byte len;
MFRC522::StatusCode status;

//-------------------------------------------

// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}

Serial.println(F("Card Detected:"));

if (mfrc522.uid.uidByte[0] == accessUID[0] && mfrc522.uid.uidByte[1] == accessUID[1] && mfrc522.uid.uidByte[2] == accessUID[2] && mfrc522.uid.uidByte[3] == accessUID[3]){

}

if (mfrc522.uid.uidByte[0] == accessUID2[0] && mfrc522.uid.uidByte[1] == accessUID2[1] && mfrc522.uid.uidByte[2] == accessUID2[2] && mfrc522.uid.uidByte[3] == accessUID2[3]){

}

//----------------------------------------

Serial.println(F("\nEnd Reading\n"));

delay(300); //change value if you want to read cards faster

delay(10);
}

How are you keeping track of ten minutes?

Also, it looks like you're using a motor to engage/disengage a lock of some kind? And during the 10 minute lockout stage, you still want to be able to scan other cards which will bypass the 10 minute locked restriction?

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