/* * -------------------------------------------------------------------------------------------------------------------- * 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------+ +--v---+ | +---------------> +-------+EXIT| |DELETE FROM| |ADD TO| | | +----+ | EEPROM | |EEPROM| | | +-----------+ +------+ +-------------------------------+ * * Use a Master Card which is act as Programmer then you can able to choose card holders who will granted access or not * * **Easy User Interface** * * Just one RFID tag needed whether Delete or Add Tags. You can choose to use Leds for output or Serial LCD module to inform users. * * **Stores Information on EEPROM** * * Information stored on non volatile Arduino's EEPROM memory to preserve Users' tag and Master Card. No Information lost * if power lost. EEPROM has unlimited Read cycle but roughly 100,000 limited Write cycle. * * **Security** * To keep it simple we are going to use Tag's Unique IDs. It's simple and not hacker proof. * * @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 // We are going to read and write PICC's UIDs from/to EEPROM #include // RC522 Module uses SPI protocol #include // Library for Mifare RC522 Devices /* Instead of a Relay you may want to use a servo. Servos can lock and unlock door locks too Relay will be used by default */ #include Servo myservo; /* For visualizing whats going on hardware we need some leds and to control door lock a relay and a wipe button (or some other hardware) Used common anode led,digitalWriting HIGH turns OFF led Mind that if you are going to use common cathode led or just seperate leds, simply comment out #define COMMON_ANODE, */ #define COMMON_ANODE //commented out because LEDS are not used #ifdef COMMON_ANODE #define LED_ON LOW #define LED_OFF HIGH #else #define LED_ON HIGH #define LED_OFF LOW #endif #define redLed 2 // Set Led Pins (they are set to all a pin not used) #define greenLed 2 #define blueLed 2 // set Proximity sensor #define echoPin 7 // This is the echo pin #define triggerPin 6 // This is the trigger pin3 #define triggerdistance 100 // cm if distance reads less than this it is triggered #define scanupdaterate 300 // ms between every scan update refresh rate // 1ms/0.139cm average pickuprange distance~106 ; minmum distance to trigger~65 cm // set buzzer #define buzzerpin 8 #define startfreq 1800 //start and programing mode Hz #define lock 2700 // for unlock and lock Hz #define unlock 2700 #define neg 500 //(negitive sound Hz) #define pos 3000 //(positive sound Hz) // set servo //#define relay or servo #define servomovetime 500 //time for the servo to move to new position and then turn off #define walkingtime 10000 #define lockdeg 30 // degrees of servo for lock position; buffered from 0 and 90 so the servo will not be manually turned past its phyical limits #define unlockdeg 140 // degrees of servo for unlock position #define servopin 4 int keyused ;// for defining if unlock was 1 with key or 0 with prox #define wipeB 5 // Button pin for WipeMode #define proxswitch 3 //switch for turning prox off boolean match = false; // initialize card match to false boolean programMode = false; // initialize programming mode to false boolean replaceMaster = false; uint8_t successRead; // Variable integer to keep if we have Successful Read from Reader 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 10 #define RST_PIN 9 MFRC522 mfrc522(SS_PIN, RST_PIN); ///////////////////////////////////////// Setup /////////////////////////////////// void setup() { Serial.print( EEPROM.length()); // attempting to display the value of length of eeprom //Arduino Pin Configuration pinMode(redLed, OUTPUT); pinMode(greenLed, OUTPUT); pinMode(blueLed, OUTPUT); pinMode(wipeB, INPUT_PULLUP); // Enable pin's pull up resistor pinMode(proxswitch, INPUT_PULLUP); pinMode(echoPin,INPUT); //prox pins pinMode(triggerPin,OUTPUT); // pinMode(relay, OUTPUT); //Be careful how relay circuit behave on while resetting or power-cycling your 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 digitalWrite(proxswitch, HIGH); //servo setup & buzzer setup myservo.attach(servopin); //locks door if power out and back on myservo.write(lockdeg); delay(servomovetime); myservo.detach(); //Protocol Configuration Serial.begin(9600); // Initialize serial communications with PC SPI.begin(); // MFRC522 Hardware uses SPI protocol mfrc522.PCD_Init(); // Initialize MFRC522 Hardware //If you set Antenna Gain to Max it will increase reading distance mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max); Serial.println(F("Access Control Example v0.1")); // For debugging purposes ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details //Wipe Code - If the Button (wipeB) Pressed while setup run (powered on) it wipes EEPROM if (digitalRead(wipeB) == LOW) { // when button pressed pin should get low, button connected to ground digitalWrite(redLed, LED_ON); // Red Led stays on to inform user we are going to wipe Serial.println(F("Wipe Button Pressed")); Serial.println(F("You have 10 seconds to Cancel")); Serial.println(F("This will be remove all records and cannot be undone")); delay(10000); // Give user enough time to cancel operation if (digitalRead(wipeB) == LOW) { // If button still be pressed, wipe EEPROM Serial.println(F("Starting Wiping EEPROM")); tone(buzzerpin,neg); //sound feedback delay(500); noTone(buzzerpin); for (uint8_t x = 0; x < 255; x = x + 1) { //Loop end of EEPROM address // x can only go to 255 if (EEPROM.read(x) == 0) { //If EEPROM address 0 // do nothing, already clear, go to the next address in order to save time and reduce writes to EEPROM Serial.print(x); Serial.println("clear: skipping"); } else { EEPROM.write(x, 0); // if not write 0 to clear, it takes 3.3mS Serial.print(x); Serial.print("writing"); } } Serial.println(F("EEPROM Successfully Wiped")); digitalWrite(redLed, LED_OFF); // visualize a successful wipe delay(200); digitalWrite(redLed, LED_ON); delay(200); digitalWrite(redLed, LED_OFF); delay(200); digitalWrite(redLed, LED_ON); delay(200); digitalWrite(redLed, LED_OFF); tone(buzzerpin,pos); delay(1000); noTone(buzzerpin); } else { Serial.println(F("Wiping Cancelled")); // Show some feedback that the wipe button did not pressed for 15 seconds digitalWrite(redLed, LED_OFF); } } // Check if master card defined, if not let user choose a master card // This also useful to just redefine the Master Card // You can keep other EEPROM records just write other than 143 to EEPROM address 1 // EEPROM address 1 should hold magical number which is '143' if (EEPROM.read(1) != 143) { Serial.println(F("No Master Card Defined")); Serial.println(F("Scan A PICC to Define as Master Card")); do { successRead = getID(); // sets successRead to 1 when we get read from reader otherwise 0 digitalWrite(blueLed, LED_ON); // Visualize Master Card need to be defined delay(200); digitalWrite(blueLed, LED_OFF); delay(200); tone(buzzerpin,pos); //in need of master card beeps delay(75); noTone(buzzerpin); tone(buzzerpin,pos); delay(75); noTone(buzzerpin); tone(buzzerpin,pos); delay(75); noTone(buzzerpin); delay(1200); } while (!successRead); // Program will not go further while you not get a successful read for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times EEPROM.write( 2 + j, readCard[j] ); // Write scanned PICC's UID to EEPROM, start from address 3 } EEPROM.write(1, 143); // Write to EEPROM we defined Master Card. Serial.println(F("Master Card Defined")); tone(buzzerpin,pos); //pos beeps feed back delay(500); noTone(buzzerpin); delay(1000); } Serial.println(F("-------------------")); Serial.println(F("Master Card's UID")); for ( uint8_t i = 0; i < 4; i++ ) { // Read Master Card's UID from EEPROM masterCard[i] = EEPROM.read(2 + i); // Write it to masterCard Serial.print(masterCard[i], HEX); } Serial.println(""); Serial.println(F("-------------------")); Serial.println(F("Everything Ready")); Serial.println(F("Waiting PICCs to be scanned")); tone(buzzerpin,startfreq); // START UP BEEPS ALL READY delay(200); noTone(buzzerpin); delay(50); tone(buzzerpin,startfreq); delay(200); noTone(buzzerpin); delay(50); tone(buzzerpin,startfreq); delay(200); noTone(buzzerpin); // cycleLeds(); // Everything ready lets give user some feedback by cycling leds // commented out because it was causeing extra beep from programing mode } ///////////////////////////////////////// Main Loop /////////////////////////////////// void loop () { do { successRead = getID(); // sets successRead to 1 when we get read from reader otherwise 0 // When device is in use if wipe button pressed for 10 seconds initialize Master Card wiping if (digitalRead(wipeB) == LOW) { // Check if button is pressed // Visualize normal operation is iterrupted by pressing wipe button Red is like more Warning to user 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 tone(buzzerpin,pos,200); //tone feedback that button was pressed // Give some feedback Serial.println(F("Wipe Button Pressed")); Serial.println(F("Master Card will be Erased! in 10 seconds")); delay(10000); // Wait 10 seconds to see user still wants to wipe if (digitalRead(wipeB) == LOW) { tone(buzzerpin,pos,200); //tone feedback that button was held long enough EEPROM.write(1, 0); // Reset Magic Number. Serial.println(F("Master card wiped! Restart device to re-program Master Card")); delay(300); tone(buzzerpin,neg); //feedback beeps to restart device delay(500); noTone(buzzerpin); delay(500); tone(buzzerpin,neg); delay(500); noTone(buzzerpin); while (1); } else { tone(buzzerpin,startfreq); // START UP BEEPS ALL READY delay(200); noTone(buzzerpin); delay(50); tone(buzzerpin,startfreq); delay(200); noTone(buzzerpin); delay(50); tone(buzzerpin,startfreq); delay(200); noTone(buzzerpin); } } if (programMode) { cycleLeds(); // Program Mode cycles through Red Green Blue waiting to read a new card } else { normalModeOn(); // Normal mode, blue Power LED is on, all others are off } } while (!successRead); //the program will not go further while you are not getting a successful read if (programMode) { if ( isMaster(readCard) ) { //When in program mode check First If master card scanned again to exit program mode Serial.println(F("Master Card Scanned")); Serial.println(F("Exiting Program Mode")); Serial.println(F("-----------------------------")); tone(buzzerpin,startfreq); // feedback for exiting programing mode delay(500); noTone(buzzerpin); delay(200); tone(buzzerpin,pos); delay(200); noTone(buzzerpin); programMode = false; return; } else { if ( findID(readCard) ) { // If scanned card is known delete it Serial.println(F("I know this PICC, removing...")); deleteID(readCard); Serial.println("-----------------------------"); Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM")); } else { // If scanned card is not known add it Serial.println(F("I do not know this PICC, adding...")); writeID(readCard); Serial.println(F("-----------------------------")); Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM")); } } } else { if ( isMaster(readCard)) { // If scanned card's ID matches Master Card's ID - enter program mode programMode = true; Serial.println(F("Hello Master - Entered Program Mode")); uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that Serial.print(F("I have ")); // stores the number of ID's in EEPROM Serial.print(count); Serial.print(F(" record(s) on EEPROM")); Serial.println(""); Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM")); Serial.println(F("Scan Master Card again to Exit Program Mode")); Serial.println(F("-----------------------------")); tone(buzzerpin,startfreq); // beeps for entering programing mode delay(500); noTone(buzzerpin); delay(200); tone(buzzerpin,startfreq); delay(200); noTone(buzzerpin); } else { if ( findID(readCard) ) { // If not, see if the card is in the EEPROM Serial.println(F("Welcome, You shall pass key used")); keyused=1; //varible flag for saying that key was used granted(300); // Open the door lock for 300 ms } 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! myservo.attach(servopin); myservo.write(unlockdeg); tone(buzzerpin,unlock); // unlocking beeps delay(250); noTone(buzzerpin); delay(servomovetime); myservo.detach(); if(digitalRead(proxswitch)==LOW){ tone(buzzerpin,neg); delay(500); noTone(buzzerpin); } delay(walkingtime);// Hold door lock open for given seconds if(digitalRead(proxswitch) == LOW & (keyused==0) ){ Serial.println("don't relock breaking loop"); tone(buzzerpin,neg); delay(500); noTone(buzzerpin); return; } myservo.attach(servopin); myservo.write(lockdeg); tone(buzzerpin,lock); // beeps delay(150); noTone(buzzerpin); delay(75); tone(buzzerpin,lock); delay(150); noTone(buzzerpin); delay(servomovetime); myservo.detach(); // 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 tone(buzzerpin,neg); // beeps delay(500); noTone(buzzerpin); } ///////////////////////////////////////// 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); delay(1200); tone(buzzerpin,startfreq); //periotic beeps to let you know your in programing mode delay(100); noTone(buzzerpin); } //////////////////////////////////////// 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 /////////////////////////////////// Proximity unlock //////////////////// Serial.print("prox and relocking switch is "); Serial.println(digitalRead(proxswitch)); if(digitalRead(proxswitch) == HIGH){ digitalWrite(triggerPin, LOW); delayMicroseconds(5); digitalWrite(triggerPin, HIGH); // make a 10usec pulse delayMicroseconds(10); digitalWrite(triggerPin, LOW); float distance = pulseIn(echoPin,HIGH); //now read the pulse that is sent back by the sensor //pulseIn returns the pulse length in use distance= distance/58; Serial.print(distance,DEC);// send the measurement to the serial monitor Serial.println(" cm. "); // switch button needs to be on as well if( ( distance < triggerdistance) && (distance >0) ){ Serial.println(F("Distance triggered")); Serial.println(F("Welcome, You shall pass key not used")); keyused=0; //defining key was not used granted(300); // Open the door lock for 300 ms } } delay(scanupdaterate); //prox scan rate } //////////////////////////////////////// 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")); tone(buzzerpin,pos); delay(500); noTone(buzzerpin); } else { failedWrite(); Serial.println(F("Failed! There is something wrong with ID or bad EEPROM")); tone(buzzerpin,1000); delay(500); noTone(buzzerpin); } } ///////////////////////////////////////// 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")); tone(buzzerpin,neg); delay(500); noTone(buzzerpin); } } ///////////////////////////////////////// Check Bytes /////////////////////////////////// boolean checkTwo ( byte a[], byte b[] ) { if ( a[0] != 0 ) // Make sure there is something in the array first match = true; // Assume they match at first for ( uint8_t k = 0; k < 4; k++ ) { // Loop 4 times if ( a[k] != b[k] ) // IF a != b then set match = false, one fails, all fail match = false; } if ( match ) { // Check to see if if match is still true return true; // Return true } else { return false; // Return false } } ///////////////////////////////////////// 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 break; // Stop looking we found it } } } ///////////////////////////////////////// Find ID From EEPROM /////////////////////////////////// boolean 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; break; // Stop looking we found it } 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 boolean isMaster( byte test[] ) { if ( checkTwo( test, masterCard ) ) return true; else return false; }