From fa8df2cc64ddb198f1380a96ad73d70074bdefbf Mon Sep 17 00:00:00 2001 From: Poroh Date: Mon, 24 Dec 2018 19:34:17 +0300 Subject: [PATCH] fix default_keys example for avoid skipping first key --- examples/rfid_default_keys/rfid_default_keys.ino | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/rfid_default_keys/rfid_default_keys.ino b/examples/rfid_default_keys/rfid_default_keys.ino index 8f3ea56..aa0c8a2 100644 --- a/examples/rfid_default_keys/rfid_default_keys.ino +++ b/examples/rfid_default_keys/rfid_default_keys.ino @@ -81,12 +81,7 @@ bool try_key(MFRC522::MIFARE_Key *key) byte buffer[18]; byte block = 0; MFRC522::StatusCode status; - - // http://arduino.stackexchange.com/a/14316 - if ( ! mfrc522.PICC_IsNewCardPresent()) - return false; - if ( ! mfrc522.PICC_ReadCardSerial()) - return false; + // Serial.println(F("Authenticating using key A...")); status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, key, &(mfrc522.uid)); if (status != MFRC522::STATUS_OK) { @@ -153,5 +148,11 @@ void loop() { // no need to try other keys for this PICC break; } + + // http://arduino.stackexchange.com/a/14316 + if ( ! mfrc522.PICC_IsNewCardPresent()) + break; + if ( ! mfrc522.PICC_ReadCardSerial()) + break; } }