/*----------------------------- 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("Card Number : ");  //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));
    }
    Serial.println();
    delay(2000);
  }