Can I have two functions that will be executed based on how long the rfid card is present at the scanner

unsigned long lastCardReadTime = 0;
unsigned long debounceDelay = 500;

if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
unsigned long currentMillis = millis();
// Check if enough time has passed since last card read
if (currentMillis - lastCardReadTime > debounceDelay) {
lastCardReadTime = currentMillis;
// Read the RFID UID
String content = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : ""));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
content.toUpperCase(); // Convert to uppercase
if (i < mfrc522.uid.size - 1) {
content.concat(" ");
}
}
// Check if the scanned UID is authorized
if (isAuthorized(content)) {
// Check for sequence
if (checkSequence(content)) {
toggleFunction();
}
} else {
Serial.println("Unauthorized UID detected.");
}
}
}
}

Welcome to the forum

You started a topic in the Uncategorised category of the forum

Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

The answer to the question in the topic title is yes

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