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.");
}
}
}
}
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