/*----------------------------- zaher.co.il -------------------------------------
  *             
  *                   Example code for RFID sensor 
  *   connection: RST --> D9, SDA --> D10, MOSI --> D11,MISO --> D12, SCK --> D13
  *     3.3V --> 3.3V (DO NOT CONNECT TO 5V), GND --> GND, IRQ --> unconnected 
  *       
  *             (Input voltage: 3.3V         Frequency: 13.56MHz)  
  *     
  *---------------------- Zaher Technological Guidance --------------------------*/

  #include <SPI.h>
  #include <MFRC522.h>
  #define SS_PIN 10
  #define RST_PIN -1
  byte i, letter;
  String code;
  MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
 
  void setup() 
  {
    Serial.begin(9600);   // Initiate a serial communication
    SPI.begin();          // Initiate  SPI bus
    mfrc522.PCD_Init();   // Initiate MFRC522
    Serial.println(" Please identify yourself by your card ... ");
    Serial.println();
    delay(1000);
  }

  void loop() 
  {
    if (!mfrc522.PICC_IsNewCardPresent()) // Look for new cards
      return; 
    if (!mfrc522.PICC_ReadCardSerial()) // Select one of the cards
      return;
    Serial.print(" UID tag : ");  //Show UID on serial monitor
    code= "";
    for (i = 0; i < mfrc522.uid.size; i++) 
    {
      if(mfrc522.uid.uidByte[i] < 0x10) //16
        Serial.print(" 0");
      else
        Serial.print(" ");
      Serial.print(mfrc522.uid.uidByte[i], HEX);
      
      code.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
      code.concat(String(mfrc522.uid.uidByte[i], HEX));
    }
      
    code.toUpperCase();
    if (code.substring(1) == "E9 EC 30 9B") //change here the UID of the card/cards that you want to give access
      Serial.println("\n Welcome Sabreen \n");
    else if (code.substring(1) == "39 E9 D2 A2") 
            Serial.println("\n Welcome Asad \n");  
          else
            Serial.println("\n Access denied \n");
   delay(3000);
  } 
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3