Advertisement
Guest User

riconoscimento tecnico rfid

a guest
May 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.54 KB | None | 0 0
  1. /*
  2. PIN:
  3. RC522 MODULE    Uno  
  4. SDA             D10
  5. SCK             D13
  6. MOSI            D11
  7. MISO            D12
  8. IRQ             N/A
  9. GND             GND
  10. RST             D9
  11. 3.3V            3.3V
  12. */
  13.  
  14. #include <SPI.h>
  15. #include <RFID.h>
  16. /* Vengono definiti PIN del RFID reader*/
  17. #define SDA_DIO 10  
  18. #define RESET_DIO 9
  19.  
  20. /* Viene creata una istanza della RFID libreria */
  21. RFID RC522(SDA_DIO, RESET_DIO);
  22.  
  23. void setup()
  24. {
  25.   Serial.begin(9600);
  26.   SPI.begin();
  27.   RC522.init();
  28.   Serial.println("***RICONOSCIMENTO TECNICO***");
  29. }
  30.  
  31. void loop()
  32. {
  33.   if ( ! mfrc522.PICC_IsNewCardPresent()) {
  34.     return;
  35.   }
  36.   if ( ! mfrc522.PICC_ReadCardSerial())
  37.   {
  38.     return;
  39.   }
  40.   //Show UID on serial monitor
  41.   Serial.print("Codice UID :");
  42.   String content= "";
  43.   byte letter;
  44.   for (byte i = 0; i < mfrc522.uid.size; i++)
  45.   {
  46.      Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
  47.      Serial.print(mfrc522.uid.uidByte[i], HEX);
  48.      content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
  49.      content.concat(String(mfrc522.uid.uidByte[i], HEX));
  50.   }
  51.   Serial.println();
  52.   Serial.print("Messaggio : ");
  53.   content.toUpperCase();
  54.     if(content.substring(1) == "DC 6B 25 D9"){
  55.       autorizzazione=true;
  56.       Serial.println("Benvenuto Nicolas!");
  57.       Serial.println("Accesso autorizzato");
  58.     Serial.println();
  59.     delay(3000);
  60.     }
  61.      
  62.     if(content.substring(1) == "BF 4B 92 DC"){
  63.       autorizzazione=true;
  64.       Serial.println("Benvenuto Nicolas!");
  65.       Serial.println("Accesso autorizzato");
  66.     Serial.println();
  67.     delay(3000);
  68.     }
  69.    
  70.     if(content.substring(1) == "C0 A3 D7 2B"){
  71.       autorizzazione=true;
  72.       Serial.println("Benvenuto Simone!");
  73.       Serial.println("Accesso autorizzato");
  74.     Serial.println();
  75.     delay(3000);
  76.     }
  77.    
  78.     if(content.substring(1) == "2D 32 E8 2B"){
  79.       autorizzazione=true;
  80.       Serial.println("Benvenuto Usman!");
  81.       Serial.println("Accesso autorizzato");
  82.     Serial.println();
  83.     delay(3000);
  84.     }
  85.    
  86.      if(content.substring(1) == "05 DC D7 2B"){
  87.       autorizzazione=true;
  88.       Serial.println("Benvenuto Luca!");
  89.       Serial.println("Accesso autorizzato");
  90.     Serial.println();
  91.     delay(3000);
  92.     }
  93.    
  94.     if(content.substring(1) == "6E C9 D8 2B"){
  95.       autorizzazione=true;
  96.       Serial.println("Benvenuto Matteo!");
  97.       Serial.println("Accesso autorizzato");
  98.     Serial.println();
  99.     delay(3000);
  100.     }
  101.     if(autorizzazione==false){
  102.     Serial.println("Accesso negato");
  103.     delay(3000);  
  104.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement