Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- PIN:
- RC522 MODULE Uno
- SDA D10
- SCK D13
- MOSI D11
- MISO D12
- IRQ N/A
- GND GND
- RST D9
- 3.3V 3.3V
- */
- #include <SPI.h>
- #include <RFID.h>
- /* Vengono definiti PIN del RFID reader*/
- #define SDA_DIO 10
- #define RESET_DIO 9
- /* Viene creata una istanza della RFID libreria */
- RFID RC522(SDA_DIO, RESET_DIO);
- void setup()
- {
- Serial.begin(9600);
- SPI.begin();
- RC522.init();
- Serial.println("***RICONOSCIMENTO TECNICO***");
- }
- void loop()
- {
- if ( ! mfrc522.PICC_IsNewCardPresent()) {
- return;
- }
- if ( ! mfrc522.PICC_ReadCardSerial())
- {
- return;
- }
- //Show UID on serial monitor
- Serial.print("Codice UID :");
- String content= "";
- byte letter;
- for (byte i = 0; i < mfrc522.uid.size; i++)
- {
- Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
- Serial.print(mfrc522.uid.uidByte[i], HEX);
- content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
- content.concat(String(mfrc522.uid.uidByte[i], HEX));
- }
- Serial.println();
- Serial.print("Messaggio : ");
- content.toUpperCase();
- if(content.substring(1) == "DC 6B 25 D9"){
- autorizzazione=true;
- Serial.println("Benvenuto Nicolas!");
- Serial.println("Accesso autorizzato");
- Serial.println();
- delay(3000);
- }
- if(content.substring(1) == "BF 4B 92 DC"){
- autorizzazione=true;
- Serial.println("Benvenuto Nicolas!");
- Serial.println("Accesso autorizzato");
- Serial.println();
- delay(3000);
- }
- if(content.substring(1) == "C0 A3 D7 2B"){
- autorizzazione=true;
- Serial.println("Benvenuto Simone!");
- Serial.println("Accesso autorizzato");
- Serial.println();
- delay(3000);
- }
- if(content.substring(1) == "2D 32 E8 2B"){
- autorizzazione=true;
- Serial.println("Benvenuto Usman!");
- Serial.println("Accesso autorizzato");
- Serial.println();
- delay(3000);
- }
- if(content.substring(1) == "05 DC D7 2B"){
- autorizzazione=true;
- Serial.println("Benvenuto Luca!");
- Serial.println("Accesso autorizzato");
- Serial.println();
- delay(3000);
- }
- if(content.substring(1) == "6E C9 D8 2B"){
- autorizzazione=true;
- Serial.println("Benvenuto Matteo!");
- Serial.println("Accesso autorizzato");
- Serial.println();
- delay(3000);
- }
- if(autorizzazione==false){
- Serial.println("Accesso negato");
- delay(3000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement