Hi!
I'm working on a RFID project, where I've scan an RFID card, and saved its unique ID into an array.
I want the Arduino to recognize multiple RFID cards, so I've created some arrays to check what card have been scanned..
I got these arrays, and when I scan a card, the ID is stored into the UniqueID array.
byte keyChain[4] = {0x4D, 0x9A, 0xE2, 0xEA};
byte creditCard[4] = {0x25, 0x30, 0xFD, 0x2B};
byte UniqueID[4];
I've been using this to check what card have been scanned:
if(UniqueID[0] == creditCard[0] && UniqueID[1] == creditCard[1] &&
UniqueID[2] == creditCard[2] && UniqueID[3] == creditCard[3]) {
Serial.println("");
Serial.println("Creditcard scanned!");
Serial.println(" ");
digitalWrite(14, HIGH);
delay(1000);
}
As you can see this code is a bit hairy, and I want to make it smaller and more elegant if that's possible.
I was thinking something like this, but I can't figure how to get it to work! Is it possible to write it this way?
if( for(int i = 0; i<4; i++) { creditCard[i] == UniqueID[i]; } )
{ doSomeStuffHere(); }