When I run this main loop, the loop waits for a RFID card to be read.
I need the program to loop constantly, and simply check the status of a card once per loop.
Been reading up on interrupts … yet not quite sure how to deal with this problem.
Could not find topic that addressed this specific issue.
Main loop code attached, as well as the library that it calls.
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) { // Look for new RFID cards
return; }
if ( ! mfrc522.PICC_ReadCardSerial()) { // Select one of the RFID cards
return; }
mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); // Dump debug info about the card. PICC_HaltA() is automatically called.
if (mfrc522.uid.uidByte[0] == 0x61) { //
Serial.println(“blue”);
} else {
Serial.println(“card”);
}
Serial.println(); // Go to next line
// read the state of the vibration sensor latch
HITState = digitalRead(HITPin); // vibration sensor latched ON by debounce circuitry?
// if it is, the HITState is HIGH
if (HITState == HIGH) {
digitalWrite(CLEARHITPin, HIGH); // reset debounce circuitry
delay(500); // wait for 1/2 second
digitalWrite(CLEARHITPin, LOW); // complete reset of debounce circuitry
LEDS = LEDS-1; // set LEDS variable for number of LEDs to light
switch (LEDS) {
case 0:
analogWrite(BARGRAPHPin, 00); // 0 LEDs ON
break;
case 1:
analogWrite(BARGRAPHPin, 13); // 1 LED ON
break;
}
} else {
}
delay(50); // wait for 0.05 second
}
MFRC522.h (22.7 KB)