Rfid probleempje

Dag,

Ik heb een sketch waarbij ik drie rfid chips wil uitlezen. Echter, elke chip mag maar door 1 specifieke reader worden geaccepteerd. Pas als alle drie aub geplaatst mag het relais uit.

In onderstaand script werkt dat niet. Wie kan helpen?

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

// PIN Numbers : RESET + SDAs
#define RST_PIN 9
#define SS_1_PIN 10
#define SS_2_PIN 6
#define SS_3_PIN 7
// Buzzer en relais
#define buzzer 4
#define relayIN 5

// List of Tags UIDs that are allowed to open the puzzle
byte tagarray[7] = {
{0x04, 0x48, 0xC4, 0x3A, 0xDA, 0x61, 0x80},
{0x04, 0x44, 0xC4, 0x3A, 0xDA, 0x61, 0x80},
{0x04, 0x40, 0xC4, 0x3A, 0xDA, 0x61, 0x80},
// {0xE6, 0xDF, 0xBB, 0x79},
};

// Inlocking status :
int tagcount = 0;
bool access = false;

#define NR_OF_READERS 3

byte ssPins = {SS_1_PIN, SS_2_PIN, SS_3_PIN};

MFRC522 mfrc522[NR_OF_READERS];

void setup() {

Serial.begin(9600);
while (!Serial); )

SPI.begin();

pinMode(relayIN, OUTPUT);
digitalWrite(relayIN, HIGH);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, LOW);

for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN);
Serial.print(F("Reader “));
Serial.print(reader);
Serial.print(F(”: "));
mfrc522[reader].PCD_DumpVersionToSerial();

}
}

void loop() {

for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {

if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {

Serial.print(F(": Card UID:"));
dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
Serial.println();

for (int x = 0; x < sizeof(tagarray); x++) // tagarray’s row
{
for (int i = 0; i < mfrc522[reader].uid.size; i++)
{
if ( mfrc522[reader].uid.uidByte != tagarray[x]*) *
* {*
* DenyingTag();*
* break;*
* }*
* else*
* {*
* if (i == mfrc522[reader].uid.size - 1) *
* {*
* AllowTag();*
* }*
* else*
* {*
* continue; *
* }*
* }*
* }*
* if (access) break; *
* }*
* if (access)*
* {*
* if (tagcount == NR_OF_READERS)
_
{_
_
OpenDoor();_
_
}_
_
else*_
* {*
* MoreTagsNeeded();*
* }*
* }*
* else*
* {*
* UnknownTag();*
* }*

* mfrc522[reader].PICC_HaltA();
mfrc522[reader].PCD_StopCrypto1();
_
}_
_
}_
_
}_
void dump_byte_array(byte * buffer, byte bufferSize) {
_
for (byte i = 0; i < bufferSize; i++) {_
_ Serial.print(buffer < 0x10 ? " 0" : " ");
Serial.print(buffer, HEX);
}
}
void printTagcount() {
Serial.print(“Tag n°”);
Serial.println(tagcount);
}
void DenyingTag()
{
tagcount = tagcount;
access = false;
}
void AllowTag()
{
tagcount = tagcount + 1;
access = true;
}
void Initialize()
{
tagcount = 0;
access = false;
}
void OpenDoor()
{
Serial.println(“Welcome! the door is now open”);
Initialize();
digitalWrite(relayIN, LOW);
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
delay(100);
digitalWrite(relayIN, HIGH);
}
void MoreTagsNeeded()
{
printTagcount();
Serial.println(“System needs more cards”);
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
delay(100);
access = false;
}
void UnknownTag()
{
Serial.println(“This Tag isn’t allowed!”);
printTagcount();
for (int flash = 0; flash < 5; flash++)
{
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
delay(100);
}
}*_

Alle chips kijken nu naar alle id's zoals je zegt. Probeer het eens op te splitsen?