currently happily under construction :)

How to read multiple RFID Readers with Alla

Arduino code – WORK IN PROGRESS!!!

 #include <Keyboard.h>

#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN         9
#define SS_1_PIN        8
#define SS_2_PIN        10

String p_scanned_uid_code = "11 22 33 44";

#define NR_OF_READERS   2
byte ssPins[] = {SS_1_PIN, SS_2_PIN};
MFRC522 mfrc522[NR_OF_READERS];                     // Create MFRC522 instance.
uint8_t reader;

void setup() {
  Serial.begin(9600);
  while (!Serial);    // Do nothing if no serial port is opened
  SPI.begin();        // Init SPI bus
  checkReaders();     // Init the readers
  Keyboard.begin();
}


void loop() {
  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN);     // Init each MFRC522 reader
    delay(1);                                              // necessary delay to detect mifare ultralight
    // Look for new cards
    if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {



      
      //Serial.print(F("Reader "));
     // Serial.print("reader no:");
      //Serial.println(reader);
      // Show some details of the PICC (that is: the tag/card)
     // Serial.print(F(": Card UID:"));

   
     //String test =  dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
      
        


       String RFIDtag = "";
        byte letter;
        for (byte i = 0; i < mfrc522[reader].uid.size; i++)
        {
        //Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
        //Serial.print(mfrc522.uid.uidByte[i], HEX);
        RFIDtag.concat(String(mfrc522[reader].uid.uidByte[i] < 0x10 ? " 0" : " "));
        RFIDtag.concat(String(mfrc522[reader].uid.uidByte[i], HEX));
        }
        // Serial.println();
        //Serial.print("Message : ");
        RFIDtag.toUpperCase();

       /*
        Serial.print("UID :");
        Serial.println(RFIDtag);
        Serial.println("----------------");
      */
      /*
      Serial.print("PREV UID :");
      Serial.print(p_scanned_uid_code);
      Serial.print(" >>>>>>>>>>  ");
*/
      //Serial.println(RFIDtag);
   
      if ( RFIDtag.substring(1) == "73 A0 87 1C" && RFIDtag.substring(1) != p_scanned_uid_code )

        {
         Serial.print ("CARD 1 on reader ");
         Serial.println(reader);
          Keyboard.write( 89 );
          p_scanned_uid_code = "73 A0 87 1C";
        
        }



        if ( RFIDtag.substring(1) == "F3 AB 79 1C" && RFIDtag.substring(1) != p_scanned_uid_code )

        {
          Serial.print ("CARD 2 on reader ");
         Serial.println(reader);
         Keyboard.write( 66 );
        p_scanned_uid_code = "F3 AB 79 1C";
        
        }








      
    } //if (mfrc522[reader].PICC_IsNewC
    else {
      // no new card found and read
      //Serial.println("no valid tag present!");
    }
    // Halt PICC
    //mfrc522[reader].PICC_HaltA();
    // Stop encryption on PCD
    //mfrc522[reader].PCD_StopCrypto1();
  } //for(uint8_t reader
}



//----------------------------------
//----------------------------------
//----------------------------------

void dump_byte_array(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}

void checkReaders() {
  boolean allworking = true;
  Serial.println();
  Serial.println("Checking all Readers!");
  for (reader = 0; reader < NR_OF_READERS; reader++) {
    delay(1);
    mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN);        // Init each MFRC522 reader
    byte verbyte = mfrc522[reader].PCD_ReadRegister(mfrc522[reader].VersionReg);
    Serial.print(F("Reader "));
    Serial.print(reader);
    Serial.print(F(": "));
    mfrc522[reader].PCD_DumpVersionToSerial();
    if (verbyte != 0x92) {
      allworking = false;
    }
    mfrc522[reader].PICC_HaltA();
    mfrc522[reader].PCD_StopCrypto1();
  }
  if (allworking == false) {
    Serial.println("There is a Problem!");
  }
  else {
    Serial.println("Readers are working");
  }
  Serial.println();
}