How to set a timer with RFID

Hello everybody , I need a help with my project , my project is a vendor machine works with RFID card , i need a help with that ( if the user took some thing ( using the card ) , he is not allowed to use the machine again until one month ( or one week ) , i already identified two card that shown in the code below. please tell me if i need to bring a piece or chip.
thanks all.
`
#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

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

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);
}
`

I understood your requirement but running arduino uno for 1 month could be little troublesome .If you can purchase nodemcu i think it will do the help you need it can connect to wifi and check the time and date from there . if you have problem creating backend then you can use the Arduino Cloud you can use it get real time and also has an option to set schedule .

You can store the data last used on the RFID card. Most cards have 1K of data storage capacity. A better idea would be to have a card you top up with an amount of money so a user can take as many items as he has payed in advance for. This data can be protected by a pair of numbers so it can't easily be tampered with.

Just a note on your physical layout diagram.

You can't connect an RC522 device directly to a 5V Arduino like the Uno without damaging the RC522. I know that is the way it is shown in virtually all the online tutorials but nevertheless it is wrong and the RC522 will be subject to early failure.

The output signals from the Arduino have to be reduced to 3V3 by using voltage dividers, as shown in this diagram:-

Let reduce it to one hours , how can i write the code ?

Thank you so much :palms_up_together:t2:

You can use millis() the max value it can hold up to 49 days i never used millis() that long you need store the card value and time when it is placed then set unlock time by setting condition like if(new_read - old_read > 60000) 1000 ms is 1 min .old_read would be the reading when the vending machine is used for first time after that when the same card is placed the value will taken in new read .So when the time period completes vending machine could be accessible for the user .

There are some drawbacks is that if the arduino went off or something went wrong the timer value will reset .if we store the values in eprom still it will not get correct time duration due to when board boots millis will also start from 0

Thank you for your comment, please help me how can i write the code

By the way how you are controlling the access for vending machine using RFID

I used the ( DumpInfo ) example and i just add these lines

byte accessUID[4] = {0x79, 0x79, 0xDA, 0xB3};

void loop(){
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]){

  Serial.println("HELLO !");
}