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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
| /*
--------------------------------------------------------------------------------------------------------------------
Example sketch/program showing An Arduino Door Access Control featuring RFID, EEPROM, Relay
--------------------------------------------------------------------------------------------------------------------
This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
This example showing a complete Door Access Control System
Simple Work Flow (not limited to) :
+---------+
+----------------------------------->READ TAGS+^------------------------------------------+
| +--------------------+ |
| | | |
| | | |
| +----v-----+ +-----v----+ |
| |MASTER TAG| |OTHER TAGS| |
| +--+-------+ ++-------------+ |
| | | | |
| | | | |
| +-----v---+ +----v----+ +----v------+ |
| +------------+READ TAGS+---+ |KNOWN TAG| |UNKNOWN TAG| |
| | +-+-------+ | +-----------+ +------------------+ |
| | | | | | |
| +----v-----+ +----v----+ +--v--------+ +-v----------+ +------v----+ |
| |MASTER TAG| |KNOWN TAG| |UNKNOWN TAG| |GRANT ACCESS| |DENY ACCESS| |
| +----------+ +---+-----+ +-----+-----+ +-----+------+ +-----+-----+ |
| | | | | |
| +----+ +----v------+ +--v---+ | +--------------->
+-------+EXIT| |DELETE FROM| |ADD TO| | |
+----+ | EEPROM | |EEPROM| | |
+-----------+ +------+ +-------------------------------+
Utilisez une carte maîtresse qui agit en tant que programmeur, vous pouvez alors choisir les titulaires de carte qui accorderont ou non l'accès
* ** Interface utilisateur simple **
Une seule étiquette RFID nécessaire, que ce soit pour supprimer ou ajouter des étiquettes. Vous pouvez choisir d'utiliser des LED pour la sortie ou un module LCD série pour informer les utilisateurs.
* ** Stocke des informations sur l'EEPROM **
Informations stockées sur la mémoire EEPROM non volatile d'Arduino pour préserver l'étiquette des utilisateurs et la carte maîtresse. Aucune information perdue
en cas de perte de puissance. L'EEPROM a un cycle de lecture illimité mais environ 100 000 cycles d'écriture limités.
* **Sécurité**
Pour faire simple, nous allons utiliser les identifiants uniques de Tag. C'est simple et non à l'épreuve des pirates.
@license Released into the public domain.
Typical pin layout used:
-----------------------------------------------------------------------------------------
MFRC522 Arduino Arduino Arduino Arduino Arduino
Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro
Signal Pin Pin Pin Pin Pin Pin
-----------------------------------------------------------------------------------------
RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
SPI SS SDA(SS) 10 53 D10 10 10
SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15
*/
#include <EEPROM.h> // We are going to read and write PICC's UIDs from/to EEPROM
#include <SPI.h> // RC522 Module uses SPI protocol
#include <MFRC522.h> // Library for Mifare RC522 Devices
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
/*
Au lieu d'un relais, vous pouvez utiliser un servo. Les servos peuvent également verrouiller et déverrouiller les serrures de porte
Le relais sera utilisé par défaut
*/
// #include <Servo.h>
/*
Pour visualiser ce qui se passe sur le matériel, nous avons besoin de quelques voyants et pour contrôler le verrouillage de la porte, un relais et un bouton d'essuyage
(ou tout autre matériel) LED d'anode commune utilisée, digitalWriting HIGH éteint la LED.
pour utiliser des leds cathodiques communes ou simplement des leds séparées, commentez simplement #define COMMON_ANODE,
*/
#define COMMON_ANODE
#ifdef COMMON_ANODE
#define LED_ON LOW
#define LED_OFF HIGH
#else
#define LED_ON HIGH
#define LED_OFF LOW
#endif
#define redLed 7 // Set Led Pins
#define greenLed 6
#define blueLed 5
#define relay 4 // Set Relay Pin
#define wipeB 3 // Button pin for WipeMode
bool programMode = false; // initialize programming mode to false
uint8_t successRead; // Entier variable à conserver si nous avons une lecture réussie à partir du lecteur
byte storedCard[4]; // Stores an ID read from EEPROM
byte readCard[4]; // Stores scanned ID read from RFID Module
byte masterCard[4]; // Stores master card's ID read from EEPROM
// Create MFRC522 instance.
#define SS_PIN 53
#define RST_PIN 12
MFRC522 mfrc522(SS_PIN, RST_PIN);
///////////////////////////////////////// Setup ///////////////////////////////////
void setup() {
//Arduino Pin Configuration
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
pinMode(wipeB, INPUT_PULLUP); // Activer la résistance pull up de la broche
pinMode(relay, OUTPUT);
// Faites attention au comportement du circuit de relais lors de la réinitialisation ou du redémarrage de votre Arduino
digitalWrite(relay, HIGH); // Make sure door is locked
digitalWrite(redLed, LED_OFF); // Make sure led is off
digitalWrite(greenLed, LED_OFF); // Make sure led is off
digitalWrite(blueLed, LED_OFF); // Make sure led is off
//Protocol Configuration
Serial.begin(9600); // Initialize serial communications with PC
SPI.begin(); // MFRC522 Hardware uses SPI protocol
mfrc522.PCD_Init(); // Initialize MFRC522 Hardware
// Si vous réglez Antenna Gain sur Max, cela augmentera la distance de lecture
//mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);
Serial.println(F("Access Control Example v0.1")); // À des fins de débogage
ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details
//Wipe Code - Si le bouton (wipeB) est enfoncé pendant l'exécution de la configuration (sous tension), il efface l'EEPROM
if (digitalRead(wipeB) == LOW) { //lorsque le bouton enfoncé, la broche doit devenir basse, le bouton est connecté à la terre
digitalWrite(redLed, LED_ON); //La LED rouge reste allumée pour informer l'utilisateur que nous allons essuyer
Serial.println(F("Bouton d'essuyage enfoncé"));
Serial.println(F("Vous avez 10 secondes pour annuler"));
Serial.println(F("Cela supprimera tous les enregistrements et ne pourra pas être annulé"));
bool buttonState = monitorWipeButton(10000); // Give user enough time to cancel operation
if (buttonState == true && digitalRead(wipeB) == LOW) { // If button still be pressed, wipe EEPROM
Serial.println(F("Starting Wiping EEPROM"));
for (uint16_t x = 0; x < EEPROM.length(); x = x + 1) { //Loop end of EEPROM address
if (EEPROM.read(x) == 0) { //If EEPROM address 0
//ne rien faire, déjà effacer, passer à l'adresse suivante pour gagner du temps et réduire les écritures en EEPROM
}
else {
EEPROM.write(x, 0); // sinon écrire 0 pour effacer, cela prend 3,3 ms
}
}
Serial.println(F("EEPROM essuyée avec succès"));
digitalWrite(redLed, LED_OFF); // visualiser un essuyage réussi
delay(200);
digitalWrite(redLed, LED_ON);
delay(200);
digitalWrite(redLed, LED_OFF);
delay(200);
digitalWrite(redLed, LED_ON);
delay(200);
digitalWrite(redLed, LED_OFF);
}
else {
Serial.println(F("Essuyage annulé")); // Affiche des commentaires indiquant que le bouton d'effacement n'a pas été enfoncé pendant 15 secondes
digitalWrite(redLed, LED_OFF);
}
}
// Vérifier si la carte maîtresse est définie, sinon laisser l'utilisateur choisir une carte maîtresse
// Ceci est également utile pour simplement redéfinir la Master Card
// Vous pouvez conserver d'autres enregistrements EEPROM en écrivant simplement autre que 143 à l'adresse EEPROM 1
// L'adresse EEPROM 1 doit contenir un numéro magique qui est '143'
if (EEPROM.read(1) != 143) {
Serial.println(F("Aucune carte maîtresse définie"));
Serial.println(F("Scanner un PICC pour le définir comme carte maîtresse"));
do {
successRead = getID(); //définit successRead à 1 lorsque nous sommes lus par le lecteur, sinon 0
digitalWrite(blueLed, LED_ON); // Visualize Master Card doit être défini
delay(200);
digitalWrite(blueLed, LED_OFF);
delay(200);
}
while (!successRead); // Le programme n'ira pas plus loin tant que vous n'obtenez pas une lecture réussie
for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times
EEPROM.write( 2 + j, readCard[j] ); // Écrire l'UID du PICC scanné dans l'EEPROM, à partir de l'adresse 3
}
EEPROM.write(1, 143); // Écrire dans l'EEPROM, nous avons défini la carte maîtresse
Serial.println(F("Master Card Defined"));
}
Serial.println(F("-------------------"));
Serial.println(F("Master Card's UID"));
for ( uint8_t i = 0; i < 4; i++ ) { // Lire l'UID de la Master Card depuis l'EEPROM
masterCard[i] = EEPROM.read(2 + i); // Écrivez-le sur masterCard
Serial.print(masterCard[i], HEX);
}
Serial.println("");
Serial.println(F("-------------------"));
Serial.println(F("Tout est prêt"));
Serial.println(F("En attente de numérisation des PICC"));
cycleLeds(); //Tout est prêt permet de donner à l'utilisateur des commentaires en cyclant les LED
}
///////////////////////////////////////// Main Loop ///////////////////////////////////
void loop () {
do {
successRead = getID(); // définit successRead à 1 lorsque nous sommes lus par le lecteur, sinon 0
// Lorsque l'appareil est en cours d'utilisation, si le bouton de nettoyage est enfoncé pendant 10 secondes, initialise le nettoyage de la carte principale
if (digitalRead(wipeB) == LOW) { // Vérifiez si le bouton est enfoncé
// Visualiser le fonctionnement normal est interrompu en appuyant sur le bouton d'effacement Le rouge est comme plus Avertissement à l'utilisateur
digitalWrite(redLed, LED_ON); // Make sure led is off
digitalWrite(greenLed, LED_OFF); // Make sure led is off
digitalWrite(blueLed, LED_OFF); // Make sure led is off
// Donnez votre avis
Serial.println(F("Bouton d'essuyage enfoncé"));
Serial.println(F("La Master Card sera effacée! en 10 secondes"));
bool buttonState = monitorWipeButton(10000); // Donnez à l'utilisateur suffisamment de temps pour annuler l'opération
if (buttonState == true && digitalRead(wipeB) == LOW) { // Si le bouton est toujours enfoncé, essuyez l'EEPROM
EEPROM.write(1, 0); // Réinitialisez le numéro magique.
Serial.println(F("Master Card effacée de l'appareil"));
Serial.println(F("Veuillez réinitialiser pour reprogrammer la carte principale"));
while (1);
}
Serial.println(F("Effacement de la carte principale annulé"));
}
if (programMode) {
cycleLeds(); // Le mode programme passe par le rouge vert bleu en attendant de lire une nouvelle carte
}
else {
normalModeOn(); // Mode normal, le voyant d'alimentation bleu est allumé, tous les autres sont éteints
}
}
while (!successRead); //e programme n'ira pas plus loin tant que vous n'obtenez pas une lecture réussie
if (programMode) {
if ( isMaster(readCard) ) { //En mode programme, vérifiez d'abord si la carte maîtresse est à nouveau scannée pour quitter le mode programme
Serial.println(F("Master Card numérisée"));
Serial.println(F("Sortie du mode programme"));
Serial.println(F("-----------------------------"));
programMode = false;
return;
}
else {
if ( findID(readCard) ) { // Si la carte numérisée est connue, supprimez-la
Serial.println(F("Je connais ce PICC, en supprimant ..."));
deleteID(readCard);
Serial.println("-----------------------------");
Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
}
else { // Si la carte numérisée n'est pas connue, ajoutez-la
Serial.println(F("Je ne connais pas ce PICC, ajoutant ..."));
writeID(readCard);
Serial.println(F("-----------------------------"));
Serial.println(F("Scanner un PICC pour AJOUTER ou SUPPRIMER vers EEPROM"));
}
}
}
else {
if ( isMaster(readCard)) { // Si l'ID de la carte numérisée correspond à l'ID de la Master Card - entrer en mode programme
programMode = true;
Serial.println(F("Hello Master - Entré en mode programme"));
uint8_t count = EEPROM.read(0); //Lisez le premier octet d'EEPROM qui
Serial.print(F("j'ai ")); // stocke le nombre d'identifiants dans l'EEPROM
Serial.print(count);
Serial.print(F(" enregistrement (s) sur EEPROM"));
Serial.println("");
Serial.println(F("Scanner un PICC pour AJOUTER ou SUPPRIMER vers EEPROM"));
Serial.println(F("Scannez à nouveau la carte maîtresse pour quitter le mode programme"));
Serial.println(F("-----------------------------"));
}
else {
if ( findID(readCard) ) { // Sinon, vérifiez si la carte est dans l'EEPROM
Serial.println(F("Bienvenue, vous passerez"));
granted(5000); // Ouvrez la serrure de la porte pendant 5 s
}
else { // If not, show that the ID was not valid
Serial.println(F("You shall not pass"));
denied();
}
}
}
}
///////////////////////////////////////// Access Granted ///////////////////////////////////
void granted ( uint16_t setDelay) {
digitalWrite(blueLed, LED_OFF); // Turn off blue LED
digitalWrite(redLed, LED_OFF); // Turn off red LED
digitalWrite(greenLed, LED_ON); // Turn on green LED
digitalWrite(relay, LOW); // Unlock door!
delay(setDelay); // Hold door lock open for given seconds
digitalWrite(relay, HIGH); // Relock door
delay(1000); // Hold green LED on for a second
}
///////////////////////////////////////// Access Denied ///////////////////////////////////
void denied() {
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_ON); // Turn on red LED
delay(1000);
}
///////////////////////////////////////// Get PICC's UID ///////////////////////////////////
uint8_t getID() {
// Getting ready for Reading PICCs
if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
return 0;
}
if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue
return 0;
}
// There are Mifare PICCs which have 4 byte or 7 byte UID care if you use 7 byte PICC
// I think we should assume every PICC as they have 4 byte UID
// Until we support 7 byte PICCs
Serial.println(F("Scanned PICC's UID:"));
for ( uint8_t i = 0; i < 4; i++) { //
readCard[i] = mfrc522.uid.uidByte[i];
Serial.print(readCard[i], HEX);
}
Serial.println("");
mfrc522.PICC_HaltA(); // Stop reading
return 1;
}
void ShowReaderDetails() {
// Get the MFRC522 software version
byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
Serial.print(F("MFRC522 Software Version: 0x"));
Serial.print(v, HEX);
if (v == 0x91)
Serial.print(F(" = v1.0"));
else if (v == 0x92)
Serial.print(F(" = v2.0"));
else
Serial.print(F(" (unknown),probably a chinese clone?"));
Serial.println("");
// When 0x00 or 0xFF is returned, communication probably failed
if ((v == 0x00) || (v == 0xFF)) {
Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
Serial.println(F("SYSTEM HALTED: Check connections."));
// Visualize system is halted
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_ON); // Turn on red LED
while (true); // do not go further
}
}
///////////////////////////////////////// Cycle Leds (Program Mode) ///////////////////////////////////
void cycleLeds() {
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
}
//////////////////////////////////////// Normal Mode Led ///////////////////////////////////
void normalModeOn () {
digitalWrite(blueLed, LED_ON); // Blue LED ON and ready to read card
digitalWrite(redLed, LED_OFF); // Make sure Red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure Green LED is off
digitalWrite(relay, HIGH); // Make sure Door is Locked
}
//////////////////////////////////////// Read an ID from EEPROM //////////////////////////////
void readID( uint8_t number ) {
uint8_t start = (number * 4 ) + 2; // Figure out starting position
for ( uint8_t i = 0; i < 4; i++ ) { // Loop 4 times to get the 4 Bytes
storedCard[i] = EEPROM.read(start + i); // Assign values read from EEPROM to array
}
}
///////////////////////////////////////// Add ID to EEPROM ///////////////////////////////////
void writeID( byte a[] ) {
if ( !findID( a ) ) { // Before we write to the EEPROM, check to see if we have seen this card before!
uint8_t num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards
uint8_t start = ( num * 4 ) + 6; // Figure out where the next slot starts
num++; // Increment the counter by one
EEPROM.write( 0, num ); // Write the new count to the counter
for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times
EEPROM.write( start + j, a[j] ); // Write the array values to EEPROM in the right position
}
successWrite();
Serial.println(F("Succesfully added ID record to EEPROM"));
}
else {
failedWrite();
Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
}
}
///////////////////////////////////////// Remove ID from EEPROM ///////////////////////////////////
void deleteID( byte a[] ) {
if ( !findID( a ) ) { // Before we delete from the EEPROM, check to see if we have this card!
failedWrite(); // If not
Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
}
else {
uint8_t num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards
uint8_t slot; // Figure out the slot number of the card
uint8_t start; // = ( num * 4 ) + 6; // Figure out where the next slot starts
uint8_t looping; // The number of times the loop repeats
uint8_t j;
uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that stores number of cards
slot = findIDSLOT( a ); // Figure out the slot number of the card to delete
start = (slot * 4) + 2;
looping = ((num - slot) * 4);
num--; // Decrement the counter by one
EEPROM.write( 0, num ); // Write the new count to the counter
for ( j = 0; j < looping; j++ ) { // Loop the card shift times
EEPROM.write( start + j, EEPROM.read(start + 4 + j)); // Shift the array values to 4 places earlier in the EEPROM
}
for ( uint8_t k = 0; k < 4; k++ ) { // Shifting loop
EEPROM.write( start + j + k, 0);
}
successDelete();
Serial.println(F("Succesfully removed ID record from EEPROM"));
}
}
///////////////////////////////////////// Check Bytes ///////////////////////////////////
bool checkTwo ( byte a[], byte b[] ) {
for ( uint8_t k = 0; k < 4; k++ ) { // Loop 4 times
if ( a[k] != b[k] ) { // IF a != b then false, because: one fails, all fail
return false;
}
}
return true;
}
///////////////////////////////////////// Find Slot ///////////////////////////////////
uint8_t findIDSLOT( byte find[] ) {
uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
for ( uint8_t i = 1; i <= count; i++ ) { // Loop once for each EEPROM entry
readID(i); // Read an ID from EEPROM, it is stored in storedCard[4]
if ( checkTwo( find, storedCard ) ) { // Check to see if the storedCard read from EEPROM
// is the same as the find[] ID card passed
return i; // The slot number of the card
}
}
}
///////////////////////////////////////// Find ID From EEPROM ///////////////////////////////////
bool findID( byte find[] ) {
uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
for ( uint8_t i = 1; i < count; i++ ) { // Loop once for each EEPROM entry
readID(i); // Read an ID from EEPROM, it is stored in storedCard[4]
if ( checkTwo( find, storedCard ) ) { // Check to see if the storedCard read from EEPROM
return true;
}
else { // If not, return false
}
}
return false;
}
///////////////////////////////////////// Write Success to EEPROM ///////////////////////////////////
// Flashes the green LED 3 times to indicate a successful write to EEPROM
void successWrite() {
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is on
delay(200);
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
delay(200);
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
delay(200);
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
delay(200);
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
delay(200);
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
delay(200);
}
///////////////////////////////////////// Write Failed to EEPROM ///////////////////////////////////
// Flashes the red LED 3 times to indicate a failed write to EEPROM
void failedWrite() {
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
delay(200);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
delay(200);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
delay(200);
}
///////////////////////////////////////// Success Remove UID From EEPROM ///////////////////////////////////
// Flashes the blue LED 3 times to indicate a success delete to EEPROM
void successDelete() {
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
delay(200);
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
}
////////////////////// Check readCard IF is masterCard ///////////////////////////////////
// Check to see if the ID passed is the master programing card
bool isMaster( byte test[] ) {
return checkTwo(test, masterCard);
}
bool monitorWipeButton(uint32_t interval) {
uint32_t now = (uint32_t)millis();
while ((uint32_t)millis() - now < interval) {
// check on every half a second
if (((uint32_t)millis() % 500) == 0) {
if (digitalRead(wipeB) != LOW)
return false;
}
}
return true;
} |
Partager