opens door Badge.
With the approach of a card or a magnetic card reader of RDIF, a selinoide folds.
A green LED indicates that the door is unlocked 3 seconds.
Then the selinoide unfolds and locks the door.
If you pass an invalid card, a buzzer sounds and a red LED flashes (optional).
Indeed, if one program that maps the valid code, invalid cards will have no effect.
Since then, we can eliminate the buzzer and the red LED.
In order to enter the card code in the skit, the console is launched and it shows the code of each card.
A single power supply 12 volts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
#define SS_PIN 10 #define RST_PIN 9 #define RELAY 3 //relay pin #define BUZZER 2 //buzzer pin MFRC522 mfrc522(SS_PIN, RST_PIN); // Branchement du lecteur de carte RC522 sur pin int led_libre = 5; // Leds indiques si code accept? ou refus? int led_refuse = 4; char st[20]; void setup() { pinMode(led_libre, OUTPUT); pinMode(led_refuse, OUTPUT); pinMode(RELAY, OUTPUT); digitalWrite(RELAY, LOW); pinMode(BUZZER, OUTPUT); noTone(BUZZER); Serial.begin(9600); SPI.begin(); // Initie le bus SPI mfrc522.PCD_Init(); // Initie le lecteur RC522 Serial.println("Approcher la carte du lecteur..."); // Initialise la console Serial.println(); } void loop() { if ( ! mfrc522.PICC_IsNewCardPresent()) // enregistre le rapprochement de la carte { return; } if ( ! mfrc522.PICC_ReadCardSerial()) // lit le code de la carte { return; } Serial.print("Tag de la carte :"); String conteudo= ""; // affiche le code de la carte sur la console byte letra; for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(mfrc522.uid.uidByte[i], HEX); conteudo.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); conteudo.concat(String(mfrc522.uid.uidByte[i], HEX)); } Serial.println(); Serial.print("Message : "); conteudo.toUpperCase(); if (conteudo.substring(1) == "BE 00 B3 89") // copier ici le code de la carte { digitalWrite(led_libre, HIGH); digitalWrite(RELAY, HIGH); Serial.println("Carte 1 - Acces libre !"); Serial.println(); delay(3000); // 3 secondes digitalWrite(led_libre, LOW); // on ?teind la led verte digitalWrite(RELAY, LOW); } if (conteudo.substring(1) == "76 96 2D AC") // copier ici le code de la carte { digitalWrite(led_libre, HIGH); digitalWrite(RELAY, HIGH); Serial.println("Carte 3 - Acces libre !"); Serial.println(); delay(3000); // 3 secondes digitalWrite(led_libre, LOW); // on ?teind la led verte digitalWrite(RELAY, LOW); } if (conteudo.substring(1) == "B3 26 B8 02") // Teste le code d'une mauvaise carte { Serial.println("Carte 2 - Acces refuse !"); // on fait clignotter la led rouge Serial.println(); for (int i= 1; i<5 ; i++) { tone(BUZZER, 300); digitalWrite(led_refuse, HIGH); delay(200); digitalWrite(led_refuse, LOW); delay(200); noTone(BUZZER); } } if (conteudo.substring(1) == "04 D2 B1 99") // Teste le code d'une mauvaise carte { Serial.println("Carte 4 - Acces refuse !"); // on fait clignotter la led rouge Serial.println(); for (int i= 1; i<5 ; i++) { tone(BUZZER, 300); digitalWrite(led_refuse, HIGH); delay(200); digitalWrite(led_refuse, LOW); delay(200); noTone(BUZZER); } } } |