# Genuino board running 3 RC522 and corresponding relays question.

..

I look forward to any advice i can get and anything that i can learn from you all.

I advise that you use consistent names.

``````MFRC522 mfrc522(SS_PIN, RST_PIN);     // Create First MFRC522 instance.
MFRC522 mfrc522_2(SS_PIN2, RST_PIN2); // Create Second MFRC522 instance.
MFRC522 mfrc522_3(SS_PIN3, RST_PIN3); // Create Third MFRC522 instance.
``````

If you are going to number two items in a set, you should number ALL items in a set.

``````    if
((id == 1 && hex_num == 6072) || (id == 2 && hex_num == 6072) || (id == 3 && hex_num == 6072)) {
switch(id){
``````

Since you don't provide cases for id not equal to 1, 2, or 3, there is no need to test that id is 1, 2, or 3. All that matters is that hex_num equals 6072.

If you keep track of the state of the relay pins, you can turn the relay on when it is off, or off when it is on.

..

..

..

..

``````    if
((id == 1 && hex_num == 6072) || (id == 2 && hex_num == 6072) || (id == 3 && hex_num == 6072)) {
switch(id){
``````

Why are you still checking id? I've told you that that is useless. If id is 5654 or -34543, there is no case for any values but 1, 2, and 3, so any other value will cause NOTHING to happen. The ONLY thing that matters is the value in hex_num. I think I mentioned that before...

``````    digitalWrite(RELAY1, LOW);
digitalWrite(RELAY2, LOW);
digitalWrite(RELAY3, LOW);
``````

It will be a real surprise what value is in pinState, won't it?

``````  if

((id == 1 && hex_num == 6072 && pinState == HIGH) || (
``````

That there be useless.

Put the clause on the line with

the if statement.

..

Just to close this off. It works perfectly now.