Add new card

Hello

I have project with arduino IDE program that used C language ... I’m using Arduino Uno and RFID RC522 to read a card .. this project work when I scan the card on reader ... So, I want to add another card that can be read a card and accepted my second card[4]={0x56,0x56,0x56,0x56} that i want to add

#include <MFRC522.h>
#include <SPI.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);

byte card_ID[4];
byte First_card_ID[4]={0x56,0x4d,0x47,0xFF};
byte i;

boolean State = false;

Void setup {

Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
}

void crd_id(){
for (byte i = 0; i < mfrc522.uid.size; i++) {
if(card_ID==First_card_ID*){
_
State=true;_
_
}_
else{
_
State=false;_
_
i=5;_
_
}_
_
}_
_
}*_
Regards,

Start by reading read this before posting a programming question and post your code using code tags unless part of it is meant to be in italics.

You could put the valid IDs in a 2 dimensional array and test each of them against the ID scanned in or if there are going to be only 2 valid cards you could at a pinch add a second array holding the second ID and repeat the code for reading the first one and check a second one. Putting the code to do the checking in a function would allow you to do this without repeating the code.

Please edit your post and use code tags; that will prevent the italics

type [code] before your code
type [/code] after your code

roony_ahmad:
Hello

I have project with arduino IDE program that used C language ... I’m using Arduino Uno and RFID RC522 to read a card .. this project work when I scan the card on reader ... So, I want to add another card that can be read a card and accepted my second card[4]={0x56,0x56,0x56,0x56} that i want to add and compare to read it

#include <MFRC522.h>

#include <SPI.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);

byte card_ID[4];
byte First_card_ID[4]={0x56,0x4d,0x47,0xFF};
byte i;

boolean State = false;

Void setup {

Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
}

void crd_id(){
for (byte i = 0; i < mfrc522.uid.size; i++) {
   if(card_ID[i]==First_card_ID[i]){
    State=true;
}
else{
    State=false;
    i=5;
}
}
}




Regards,
  i=5;

"break;" would be less error -prone.

Hello,
I 'm using the code below to read my card... it works well.
But now I want to add another card ... I added and compare it but it's not working
My second card is {0x56,0x56,0x56,0x56}

#include <MFRC522.h>
#include <SPI.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);

byte card_ID[4];
byte First_card_ID[4]={0x55,0x44,0x67,0xFF};
byte i;

boolean State = false;

Void setup {

Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
}

//to compare the card
void crd_id(){
for (byte i = 0; i < mfrc522.uid.size; i++) {
    if(card_ID==First_card_ID){
     State=true;
}
else{
     State=false;
     i=5;
}
}
}
//verification
                com_id();
                if(State==true)
                {
                   accept();
                }
                else
                {
                  unacceptable();
                }

Regards,

Why have you started a second thread for this ?

Did you not like the answers in Add new card - Programming Questions - Arduino Forum

UKHeliBob:
Why have you started a second thread for this ?

Did you not like the answers in Add new card - Programming Questions - Arduino Forum

No not like that, but the problem did not resolve

Threads merged.

but the problem did not resolve

Post the code where you tried to add a second card. Describe what the code ACTUALLY does. Describe how that differs from what you expect. Then, we can explain why your expectations are wrong, and how to fix them (or the code).