Hello everyone,
I am constructing a beer vending machine that uses RFID cards to allow users to retrieve a beer from the vending machine. (Just for personal use at home not for business purposes) The code is still a work in progress, but the program I have at the moment works fine except for the following issue...
When a card is read by the RFID shield, it doesn't seem to recognize that the cards are different. It just keeps displaying the "Hello Admin" message even though the card numbers are different. I've tried using different IF/ELSE statements but it hasn't seemed to make any difference. I've also tried searching Google but that didn't seem to turn up anything.
Could someone please tell me what I'm doing wrong here? Or point me in the right direction?
Any help is greatly appreciated
Parts used: Arduino Uno, Adafruit RFID shield, Adafruit LCD shield
This is the chunk of code that is giving me the issue (There are 11 cards in total):
uint8_t i=0;
void loop(void) {
uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (uidLength == 0xE1,0x46,0x50,0x23){
lcd.setCursor(0, 0);
lcd.print("Hello Admin ");
lcd.setCursor(0, 1);
lcd.print("Enjoy the Beer!");
delay (5000);
lcd.setCursor(0, 0);
lcd.print("Waiting for ");
lcd.setCursor(0, 1);
lcd.print("Next Card ");
}
else if (uidLength == 0xC9,0xED,0x8A,0x0A){
lcd.setCursor(0, 0);
lcd.print("Hello Colin ");
lcd.setCursor(0, 1);
lcd.print("Enjoy the Beer!");
delay (5000);
lcd.setCursor(0, 0);
lcd.print("Waiting for ");
lcd.setCursor(0, 1);
lcd.print("Next Card ");
}
Also, is it possible to run 11 different counters on an Uno?