# More than one rfid card to read on one reader for lock

**URL:** <https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704>\
**Category:** Programming\
**Created:** [November 25, 2022, 4:05am UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704 "2022-11-25T04:05:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 4:05am UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/1 "2022-11-25T04:05:54Z")

</div>

Below is the the code im using im trying to find a way to add more than one card that has access to the lock. for an example i have these 2 card ids i would like to have access "BA4 23 ED 80 & 53 3A 32 98"

```cpp
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>

#define LIST_SIZE 2
#define SS_PIN 10
#define RST_PIN 9
String UID = "BA 42 ED 80";
byte lock = 0;

Servo servo;
LiquidCrystal_I2C lcd(0x27,16,2);
MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  servo.write(180);
  lcd.init();
  lcd.backlight();
  servo.attach(3);
  SPI.begin();
  rfid.PCD_Init();
}

void loop() {
  lcd.setCursor(4,0);
  lcd.print("W");
  lcd.print("e");
  lcd.print("l");
  lcd.print("c");
  lcd.print("o");
  lcd.print("m");
  lcd.print("e");
  lcd.setCursor(1, 1);
  lcd.print("S");
  lcd.print("c");
  lcd.print("a");
  lcd.print("n");
  lcd.print(" ");
  lcd.print("C");
  lcd.print("a");
  lcd.print("r");
  lcd.print("d");

  if ( ! rfid.PICC_IsNewCardPresent())
    return;
  if ( ! rfid.PICC_ReadCardSerial())
    return;

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("S");
  lcd.print("c");
  lcd.print("a");
  lcd.print("n");
  lcd.print("n");
  lcd.print("i");
  lcd.print("n");
  lcd.print("g");
  Serial.print("nicks card:");
  String ID = "";
  for (byte i = 0; i < rfid.uid.size; i++) {
    lcd.print(".");
    ID.concat(String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " "));
    ID.concat(String(rfid.uid.uidByte[i], HEX));
    delay(300);
  }
  ID.toUpperCase();

  if (ID.substring(1) == UID && lock == 0 ) {
    servo.write(25);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("D");
    lcd.print("o");
    lcd.print("o");
    lcd.print("r");
    lcd.print("'");
    lcd.print("s");
    lcd.print(" ");
    lcd.print("O");
    lcd.print("p");
    lcd.print("e");
    lcd.print("n");
    delay(1500);
    lcd.clear();
    lock = 1;
  } else if (ID.substring(1) == UID && lock == 1 ) {
    servo.write(160);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("D");
    lcd.print("o");
    lcd.print("o");
    lcd.print("r");
    lcd.print("'");
    lcd.print("s");
    lcd.print(" ");
    lcd.print("L");
    lcd.print("o");
    lcd.print("c");
    lcd.print("k");
    lcd.print("e");
    lcd.print("d");
    delay(1500);
    lcd.clear();
    lock = 0;
  } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Wrong card!");
    delay(1500);
    lcd.clear();
  }
}

```

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 4:55am UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/2 "2022-11-25T04:55:15Z")

</div>

Hi whitewolf,

welcome to the forum  
you should post your code as a code-section.  
So please **RE** -edit your posting

> [@Make experienced users help: two ways to quickly post code as a code-section](https://forum.arduino.cc/t/make-experienced-users-help-two-ways-to-quickly-post-code-as-a-code-section/937298):
>
> Hi newcomer, This thread wants to show you how you can speed-up getting helpful answers with small effort. If you manage at least to post this way. You have the sympathy of the experienced users. If you are willing to invest another 20 minutes these 20 minutes extra-time will save you a minimum of 200 minutes to finish your project. always post your full sketch. As a code-section from the very first to the very last line A code-section has a small height =\> keeps your posting "short" but e…

---

<div class="post-metadata">

**Author:** ![red\_car](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@red\_car](https://forum.arduino.cc/u/red_car)\
**Post date:** [November 25, 2022, 6:07am UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/3 "2022-11-25T06:07:16Z")

</div>

> [@whitew0lf](#):
>
> lcd.print("W");

You know you can send more than one character at a time to the LCD?

You could put valid cards in an array...

```arduino
#define LIST_SIZE 2

String UIDList[LIST_SIZE] = {"BA 42 ED 80",
                             "53 3A 32 98"};

```

...and create a routine to check if the card you read is in the list...

```arduino
boolean validCard (String checkCard)
{
  for (uint8_t x = 0; x < LIST_SIZE; x++)
  {
    if (checkCard == UIDList[x])
      return true;
  }

  return false;
}

```

... and then replace this...

```arduino
  if (ID.substring(1) == UID &&

```

with this...

```arduino
  if (validCard(ID.substring(1)) &&

```

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 7:38pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/4 "2022-11-25T19:38:26Z")

</div>

not sure how to post it as a code section

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 8:02pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/5 "2022-11-25T20:02:52Z")

</div>

> [@whitew0lf](#):
>
> not sure how to post it as a code section

Did you **read** this tutorial?

> [@Make experienced users help: two ways to quickly post code as a code-section](https://forum.arduino.cc/t/make-experienced-users-help-two-ways-to-quickly-post-code-as-a-code-section/937298):
>
> Hi newcomer, This thread wants to show you how you can speed-up getting helpful answers with small effort. If you manage at least to post this way. You have the sympathy of the experienced users. If you are willing to invest another 20 minutes these 20 minutes extra-time will save you a minimum of 200 minutes to finish your project. always post your full sketch. As a code-section from the very first to the very last line A code-section has a small height =\> keeps your posting "short" but e…

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 8:13pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/6 "2022-11-25T20:13:46Z")

</div>

got it in a code section now

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 8:21pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/7 "2022-11-25T20:21:48Z")

</div>

well done. As an additional hint: Whenever you want to post a **modificated** code  
post the code in a **new** posting. Posting **new** postings is the usual way.  
It is really accepted if a thread becomes hundreds of posts long.

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 8:23pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/8 "2022-11-25T20:23:22Z")

</div>

this is what ive got so far but when i upload it theres a problem "could not convert 'servo.Servo::write(25)' from 'void' to 'bool' pops up and highlights "servo.write(25);"

```cpp
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>

#define LIST_SIZE 2
#define SS_PIN 10
#define RST_PIN 9
String UIDList[LIST_SIZE] = {"BA 42 ED 80",
                             "53 3A 32 98"};
byte lock = 0;
boolean validCard (String checkCard)
{
  for (uint8_t x = 0; x < LIST_SIZE; x++)
  {
    if (checkCard == UIDList[x])
      return true;
  }

  return false;
}
Servo servo;
LiquidCrystal_I2C lcd(0x27,16,2);
MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  servo.write(180);
  lcd.init();
  lcd.backlight();
  servo.attach(3);
  SPI.begin();
  rfid.PCD_Init();
}

void loop() {
  lcd.setCursor(4,0);
  lcd.print("W");
  lcd.print("e");
  lcd.print("l");
  lcd.print("c");
  lcd.print("o");
  lcd.print("m");
  lcd.print("e");
  lcd.setCursor(1, 1);
  lcd.print("S");
  lcd.print("c");
  lcd.print("a");
  lcd.print("n");
  lcd.print(" ");
  lcd.print("C");
  lcd.print("a");
  lcd.print("r");
  lcd.print("d");

  if ( ! rfid.PICC_IsNewCardPresent())
    return;
  if ( ! rfid.PICC_ReadCardSerial())
    return;

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("S");
  lcd.print("c");
  lcd.print("a");
  lcd.print("n");
  lcd.print("n");
  lcd.print("i");
  lcd.print("n");
  lcd.print("g");
  Serial.print("nicks card:");
  String ID = "";
  for (byte i = 0; i < rfid.uid.size; i++) {
    lcd.print(".");
    ID.concat(String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " "));
    ID.concat(String(rfid.uid.uidByte[i], HEX));
    delay(300);
  }
  ID.toUpperCase();

if (validCard(ID.substring(1)) &&
    servo.write(25);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("D");
    lcd.print("o");
    lcd.print("o");
    lcd.print("r");
    lcd.print("'");
    lcd.print("s");
    lcd.print(" ");
    lcd.print("O");
    lcd.print("p");
    lcd.print("e");
    lcd.print("n");
    delay(1500);
    lcd.clear();
    lock = 1;
  } else if (ID.substring(1) == UID && lock == 1 ) {
    servo.write(160);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("D");
    lcd.print("o");
    lcd.print("o");
    lcd.print("r");
    lcd.print("'");
    lcd.print("s");
    lcd.print(" ");
    lcd.print("L");
    lcd.print("o");
    lcd.print("c");
    lcd.print("k");
    lcd.print("e");
    lcd.print("d");
    delay(1500);
    lcd.clear();
    lock = 0;
  } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Wrong card!");
    delay(1500);
    lcd.clear();
  }
}

```

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 8:28pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/9 "2022-11-25T20:28:30Z")

</div>

```cpp
if (validCard(ID.substring(1)) &&
    servo.write(25);

```

The line with the "if" has a boolean and-operator " **&&**"behind the closing parenthesis  
if (validCard(ID.substring(1)) **&&**

This makes the compiler expextion a boolean expression  
but the function-call  
servo.write(25);

does **not** return a boolean value  
I guess this should be simply a semicolon  
if (validCard(ID.substring(1)) **;**

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 8:32pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/10 "2022-11-25T20:32:41Z")

</div>

> [@StefanL38](#):
>
> if (validCard(ID.substring(1)) **;**

```arduino
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>

#define LIST_SIZE 2
#define SS_PIN 10
#define RST_PIN 9
String UIDList[LIST_SIZE] = {"BA 42 ED 80",
                             "53 3A 32 98"};
byte lock = 0;
if (validCard(ID.substring(1)) ;
Servo servo;
LiquidCrystal_I2C lcd(0x27,16,2);
MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  servo.write(180);
  lcd.init();
  lcd.backlight();
  servo.attach(3);
  SPI.begin();
  rfid.PCD_Init();
}

void loop() {
  lcd.setCursor(4,0);
  lcd.print("W");
  lcd.print("e");
  lcd.print("l");
  lcd.print("c");
  lcd.print("o");
  lcd.print("m");
  lcd.print("e");
  lcd.setCursor(1, 1);
  lcd.print("S");
  lcd.print("c");
  lcd.print("a");
  lcd.print("n");
  lcd.print(" ");
  lcd.print("C");
  lcd.print("a");
  lcd.print("r");
  lcd.print("d");

  if ( ! rfid.PICC_IsNewCardPresent())
    return;
  if ( ! rfid.PICC_ReadCardSerial())
    return;

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("S");
  lcd.print("c");
  lcd.print("a");
  lcd.print("n");
  lcd.print("n");
  lcd.print("i");
  lcd.print("n");
  lcd.print("g");
  Serial.print("nicks card:");
  String ID = "";
  for (byte i = 0; i < rfid.uid.size; i++) {
    lcd.print(".");
    ID.concat(String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " "));
    ID.concat(String(rfid.uid.uidByte[i], HEX));
    delay(300);
  }
  ID.toUpperCase();

if (validCard(ID.substring(1)) &&
    servo.write(25);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("D");
    lcd.print("o");
    lcd.print("o");
    lcd.print("r");
    lcd.print("'");
    lcd.print("s");
    lcd.print(" ");
    lcd.print("O");
    lcd.print("p");
    lcd.print("e");
    lcd.print("n");
    delay(1500);
    lcd.clear();
    lock = 1;
  } else if (ID.substring(1) == UID && lock == 1 ) {
    servo.write(160);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("D");
    lcd.print("o");
    lcd.print("o");
    lcd.print("r");
    lcd.print("'");
    lcd.print("s");
    lcd.print(" ");
    lcd.print("L");
    lcd.print("o");
    lcd.print("c");
    lcd.print("k");
    lcd.print("e");
    lcd.print("d");
    delay(1500);
    lcd.clear();
    lock = 0;
  } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Wrong card!");
    delay(1500);
    lcd.clear();
  }
}

```

like this?

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 8:43pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/11 "2022-11-25T20:43:14Z")

</div>

> [@whitew0lf](#):
>
> like this?

No. I'm sorry this makes no sense at all.  
I was too quick with my last reply

I guess you want the lines of code below the if-conditions executed only if the if-condition is true  
so it should be like this  
.  
complete sketch:

```arduino
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>

#define LIST_SIZE 2
#define SS_PIN 10
#define RST_PIN 9
String UIDList[LIST_SIZE] = {"BA 42 ED 80",
                             "53 3A 32 98"
                            };
byte lock = 0;
boolean validCard (String checkCard) {
  for (uint8_t x = 0; x < LIST_SIZE; x++) {
    if (checkCard == UIDList[x])
      return true;
  }
  return false;
}

Servo servo;
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  servo.write(180);
  lcd.init();
  lcd.backlight();
  servo.attach(3);
  SPI.begin();
  rfid.PCD_Init();
}

void loop() {
  lcd.setCursor(4, 0);
  lcd.print("W");
  lcd.print("e");
  lcd.print("l");
  lcd.print("c");
  lcd.print("o");
  lcd.print("m");
  lcd.print("e");
  lcd.setCursor(1, 1);
  lcd.print("S");
  lcd.print("c");
  lcd.print("a");
  lcd.print("n");
  lcd.print(" ");
  lcd.print("C");
  lcd.print("a");
  lcd.print("r");
  lcd.print("d");

  if ( ! rfid.PICC_IsNewCardPresent())
    return;
  
  if ( ! rfid.PICC_ReadCardSerial())
    return;
  
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("S");
  lcd.print("c");
  lcd.print("a");
  lcd.print("n");
  lcd.print("n");
  lcd.print("i");
  lcd.print("n");
  lcd.print("g");
  Serial.print("nicks card:");
  String ID = "";
  
  for (byte i = 0; i < rfid.uid.size; i++) {
    lcd.print(".");
    ID.concat(String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " "));
    ID.concat(String(rfid.uid.uidByte[i], HEX));
    delay(300);
  }
  
  ID.toUpperCase();
  
  if (validCard(ID.substring(1)) ) {
  servo.write(25);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("D");
    lcd.print("o");
    lcd.print("o");
    lcd.print("r");
    lcd.print("'");
    lcd.print("s");
    lcd.print(" ");
    lcd.print("O");
    lcd.print("p");
    lcd.print("e");
    lcd.print("n");
    delay(1500);
    lcd.clear();
    lock = 1;
  } 
  else if (ID.substring(1) == UID && lock == 1 ) {
  //else if (ID.substring(1) == ID && lock == 1 ) {
    servo.write(160);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("D");
    lcd.print("o");
    lcd.print("o");
    lcd.print("r");
    lcd.print("'");
    lcd.print("s");
    lcd.print(" ");
    lcd.print("L");
    lcd.print("o");
    lcd.print("c");
    lcd.print("k");
    lcd.print("e");
    lcd.print("d");
    delay(1500);
    lcd.clear();
    lock = 0;
  } 
  else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Wrong card!");
    delay(1500);
    lcd.clear();
  }
}
```

what is **UID**??

I haven't analysed the complete logic of your code.  
You have to declare a variable "UID" if you want to use a variable named UID

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 8:49pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/12 "2022-11-25T20:49:51Z")

</div>

this works for both key cards to open it now but wont lock it

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 8:55pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/13 "2022-11-25T20:55:35Z")

</div>

You should clearly describe what you mean with " **this**"

The code I have posted does not compile

```cpp
exit status 1
'UID' was not declared in this scope

```

This is the reason why I'm asking **what is UID**?  
If I shall give more support I want to suggest something:  
adding serial debug-output with three macros that reduce writing three lines of code to a single line.

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 8:59pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/14 "2022-11-25T20:59:41Z")

</div>

im not sure red\_car said to add it. the lock is working but only to open it.

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 9:01pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/15 "2022-11-25T21:01:53Z")

</div>

> [@whitew0lf](#):
>
> im not sure red\_car said to add **it**. the lock is working but only to open it.

dear lovely whitew0lf,

can you please please be specific what you mean by "it" ?  
And can you please answer my question about

> [@StefanL38](#):
>
> If I shall give more support I want to suggest something:  
> adding serial debug-output with three macros that reduce writing three lines of code to a single line.

best regards Stefan

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 9:06pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/16 "2022-11-25T21:06:22Z")

</div>

im not sure what the UID is Red\_Car repplied to me and said to add this in.

```cpp
You could put valid cards in an array...

#define LIST_SIZE 2

String UIDList[LIST_SIZE] = {"BA 42 ED 80",
                             "53 3A 32 98"};
...and create a routine to check if the card you read is in the list...

boolean validCard (String checkCard)
{
  for (uint8_t x = 0; x < LIST_SIZE; x++)
  {
    if (checkCard == UIDList[x])
      return true;
  }

  return false;
}
... and then replace this...

  if (ID.substring(1) == UID &&
with this...

  if (validCard(ID.substring(1)) &&

```

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 9:10pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/17 "2022-11-25T21:10:00Z")

</div>

> [@whitew0lf](#):
>
> `You could put valid cards in an array...`

Do you know what an array is?

Aha I understand. Red\_Car aded an array where each element of the array holds one card-number  
This is this part of the code

```arduino
String UIDList[LIST_SIZE] = {
  "BA 42 ED 80",
  "53 3A 32 98"
                            };

```

So in your line of code

```arduino
  else if (ID.substring(1) == UID && lock == 1 ) {

```

Why did you wrote  
else if (ID.substring(1) == **UID** && lock == 1 ) {  
???

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 9:11pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/18 "2022-11-25T21:11:47Z")

</div>

oh that part was added in from who ever made the original file. not all of the file is my work.

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [November 25, 2022, 9:12pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/19 "2022-11-25T21:12:33Z")

</div>

as the code is now the code does **not** compile

---

<div class="post-metadata">

**Author:** ![whitew0lf](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@whitew0lf](https://forum.arduino.cc/u/whitew0lf)\
**Post date:** [November 25, 2022, 9:12pm UTC](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704/20 "2022-11-25T21:12:44Z")

</div>

the only things im using is an Arduino uno with an rfid reader and a lcd screen and one servo

[Next page](https://forum.arduino.cc/t/more-than-one-rfid-card-to-read-on-one-reader-for-lock/1057704.md?page=2)
