Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.32 KB | None | 0 0
  1. /*
  2. * --------------------------------------------------------------------------------------------------------------------
  3. * Example sketch/program showing An Arduino Door Access Control featuring RFID, EEPROM, Relay
  4. * --------------------------------------------------------------------------------------------------------------------
  5. * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
  6. *
  7. * This example showing a complete Door Access Control System
  8.  
  9. Simple Work Flow (not limited to) :
  10. +---------+
  11. +----------------------------------->READ TAGS+^------------------------------------------+
  12. | +--------------------+ |
  13. | | | |
  14. | | | |
  15. | +----v-----+ +-----v----+ |
  16. | |MASTER TAG| |OTHER TAGS| |
  17. | +--+-------+ ++-------------+ |
  18. | | | | |
  19. | | | | |
  20. | +-----v---+ +----v----+ +----v------+ |
  21. | +------------+READ TAGS+---+ |KNOWN TAG| |UNKNOWN TAG| |
  22. | | +-+-------+ | +-----------+ +------------------+ |
  23. | | | | | | |
  24. | +----v-----+ +----v----+ +--v--------+ +-v----------+ +------v----+ |
  25. | |MASTER TAG| |KNOWN TAG| |UNKNOWN TAG| |GRANT ACCESS| |DENY ACCESS| |
  26. | +----------+ +---+-----+ +-----+-----+ +-----+------+ +-----+-----+ |
  27. | | | | | |
  28. | +----+ +----v------+ +--v---+ | +--------------->
  29. +-------+EXIT| |DELETE FROM| |ADD TO| | |
  30. +----+ | EEPROM | |EEPROM| | |
  31. +-----------+ +------+ +-------------------------------+
  32.  
  33. *
  34. * Use a Master Card which is act as Programmer then you can able to choose card holders who will granted access or not
  35. *
  36. * **Easy User Interface**
  37. *
  38. * 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.
  39. *
  40. * **Stores Information on EEPROM**
  41. *
  42. * Information stored on non volatile Arduino's EEPROM memory to preserve Users' tag and Master Card. No Information lost
  43. * if power lost. EEPROM has unlimited Read cycle but roughly 100,000 limited Write cycle.
  44. *
  45. * **Security**
  46. * To keep it simple we are going to use Tag's Unique IDs. It's simple and not hacker proof.
  47. *
  48. * @license Released into the public domain.
  49. *
  50. * Typical pin layout used:
  51. * -----------------------------------------------------------------------------------------
  52. * MFRC522 Arduino Arduino Arduino Arduino Arduino
  53. * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro
  54. * Signal Pin Pin Pin Pin Pin Pin
  55. * -----------------------------------------------------------------------------------------
  56. * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
  57. * SPI SS SDA(SS) 10 53 D10 10 10
  58. * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
  59. * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
  60. * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15
  61. */
  62.  
  63. #include <EEPROM.h> // We are going to read and write PICC's UIDs from/to EEPROM
  64. #include <SPI.h> // RC522 Module uses SPI protocol
  65. #include <MFRC522.h> // Library for Mifare RC522 Devices
  66.  
  67. /*
  68. Instead of a Relay you may want to use a servo. Servos can lock and unlock door locks too
  69. Relay will be used by default
  70. */
  71.  
  72. // #include <Servo.h>
  73.  
  74. /*
  75. For visualizing whats going on hardware we need some leds and to control door lock a relay and a wipe button
  76. (or some other hardware) Used common anode led,digitalWriting HIGH turns OFF led Mind that if you are going
  77. to use common cathode led or just seperate leds, simply comment out #define COMMON_ANODE,
  78. */
  79.  
  80. #define COMMON_ANODE
  81.  
  82. #ifdef COMMON_ANODE
  83. #define LED_ON LOW
  84. #define LED_OFF HIGH
  85. #else
  86. #define LED_ON HIGH
  87. #define LED_OFF LOW
  88. #endif
  89.  
  90. #define redLed 7 // Set Led Pins
  91. #define greenLed 6
  92. #define blueLed 5
  93.  
  94. #define relay 4 // Set Relay Pin
  95. #define wipeB 3 // Button pin for WipeMode
  96.  
  97. boolean match = false; // initialize card match to false
  98. boolean programMode = false; // initialize programming mode to false
  99. boolean replaceMaster = false;
  100.  
  101. uint8_t successRead; // Variable integer to keep if we have Successful Read from Reader
  102.  
  103. byte storedCard[4]; // Stores an ID read from EEPROM
  104. byte readCard[4]; // Stores scanned ID read from RFID Module
  105. byte masterCard[4]; // Stores master card's ID read from EEPROM
  106.  
  107. // Create MFRC522 instance.
  108. #define SS_PIN 10
  109. #define RST_PIN 9
  110. MFRC522 mfrc522(SS_PIN, RST_PIN);
  111.  
  112. ///////////////////////////////////////// Setup ///////////////////////////////////
  113. void setup() {
  114. //Arduino Pin Configuration
  115. pinMode(redLed, OUTPUT);
  116. pinMode(greenLed, OUTPUT);
  117. pinMode(blueLed, OUTPUT);
  118. pinMode(wipeB, INPUT_PULLUP); // Enable pin's pull up resistor
  119. pinMode(relay, OUTPUT);
  120. //Be careful how relay circuit behave on while resetting or power-cycling your Arduino
  121. digitalWrite(relay, HIGH); // Make sure door is locked
  122. digitalWrite(redLed, LED_OFF); // Make sure led is off
  123. digitalWrite(greenLed, LED_OFF); // Make sure led is off
  124. digitalWrite(blueLed, LED_OFF); // Make sure led is off
  125.  
  126. //Protocol Configuration
  127. Serial.begin(9600); // Initialize serial communications with PC
  128. SPI.begin(); // MFRC522 Hardware uses SPI protocol
  129. mfrc522.PCD_Init(); // Initialize MFRC522 Hardware
  130.  
  131. //If you set Antenna Gain to Max it will increase reading distance
  132. //mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);
  133.  
  134. Serial.println(F("Access Control Example v0.1")); // For debugging purposes
  135. ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details
  136.  
  137. //Wipe Code - If the Button (wipeB) Pressed while setup run (powered on) it wipes EEPROM
  138. if (digitalRead(wipeB) == LOW) { // when button pressed pin should get low, button connected to ground
  139. digitalWrite(redLed, LED_ON); // Red Led stays on to inform user we are going to wipe
  140. Serial.println(F("Wipe Button Pressed"));
  141. Serial.println(F("You have 15 seconds to Cancel"));
  142. Serial.println(F("This will be remove all records and cannot be undone"));
  143. delay(15000); // Give user enough time to cancel operation
  144. if (digitalRead(wipeB) == LOW) { // If button still be pressed, wipe EEPROM
  145. Serial.println(F("Starting Wiping EEPROM"));
  146. for (uint8_t x = 0; x < EEPROM.length(); x = x + 1) { //Loop end of EEPROM address
  147. if (EEPROM.read(x) == 0) { //If EEPROM address 0
  148. // do nothing, already clear, go to the next address in order to save time and reduce writes to EEPROM
  149. }
  150. else {
  151. EEPROM.write(x, 0); // if not write 0 to clear, it takes 3.3mS
  152. }
  153. }
  154. Serial.println(F("EEPROM Successfully Wiped"));
  155. digitalWrite(redLed, LED_OFF); // visualize a successful wipe
  156. delay(200);
  157. digitalWrite(redLed, LED_ON);
  158. delay(200);
  159. digitalWrite(redLed, LED_OFF);
  160. delay(200);
  161. digitalWrite(redLed, LED_ON);
  162. delay(200);
  163. digitalWrite(redLed, LED_OFF);
  164. }
  165. else {
  166. Serial.println(F("Wiping Cancelled")); // Show some feedback that the wipe button did not pressed for 15 seconds
  167. digitalWrite(redLed, LED_OFF);
  168. }
  169. }
  170. // Check if master card defined, if not let user choose a master card
  171. // This also useful to just redefine the Master Card
  172. // You can keep other EEPROM records just write other than 143 to EEPROM address 1
  173. // EEPROM address 1 should hold magical number which is '143'
  174. if (EEPROM.read(1) != 143) {
  175. Serial.println(F("No Master Card Defined"));
  176. Serial.println(F("Scan A PICC to Define as Master Card"));
  177. do {
  178. successRead = getID(); // sets successRead to 1 when we get read from reader otherwise 0
  179. digitalWrite(blueLed, LED_ON); // Visualize Master Card need to be defined
  180. delay(200);
  181. digitalWrite(blueLed, LED_OFF);
  182. delay(200);
  183. }
  184. while (!successRead); // Program will not go further while you not get a successful read
  185. for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times
  186. EEPROM.write( 2 + j, readCard[j] ); // Write scanned PICC's UID to EEPROM, start from address 3
  187. }
  188. EEPROM.write(1, 143); // Write to EEPROM we defined Master Card.
  189. Serial.println(F("Master Card Defined"));
  190. }
  191. Serial.println(F("-------------------"));
  192. Serial.println(F("Master Card's UID"));
  193. for ( uint8_t i = 0; i < 4; i++ ) { // Read Master Card's UID from EEPROM
  194. masterCard[i] = EEPROM.read(2 + i); // Write it to masterCard
  195. Serial.print(masterCard[i], HEX);
  196. }
  197. Serial.println("");
  198. Serial.println(F("-------------------"));
  199. Serial.println(F("Everything Ready"));
  200. Serial.println(F("Waiting PICCs to be scanned"));
  201. cycleLeds(); // Everything ready lets give user some feedback by cycling leds
  202. }
  203.  
  204.  
  205. ///////////////////////////////////////// Main Loop ///////////////////////////////////
  206. void loop () {
  207. do {
  208. successRead = getID(); // sets successRead to 1 when we get read from reader otherwise 0
  209. // When device is in use if wipe button pressed for 10 seconds initialize Master Card wiping
  210. if (digitalRead(wipeB) == LOW) { // Check if button is pressed
  211. // Visualize normal operation is iterrupted by pressing wipe button Red is like more Warning to user
  212. digitalWrite(redLed, LED_ON); // Make sure led is off
  213. digitalWrite(greenLed, LED_OFF); // Make sure led is off
  214. digitalWrite(blueLed, LED_OFF); // Make sure led is off
  215. // Give some feedback
  216. Serial.println(F("Wipe Button Pressed"));
  217. Serial.println(F("Master Card will be Erased! in 10 seconds"));
  218. delay(10000); // Wait 10 seconds to see user still wants to wipe
  219. if (digitalRead(wipeB) == LOW) {
  220. EEPROM.write(1, 0); // Reset Magic Number.
  221. Serial.println(F("Restart device to re-program Master Card"));
  222. while (1);
  223. }
  224. }
  225. if (programMode) {
  226. cycleLeds(); // Program Mode cycles through Red Green Blue waiting to read a new card
  227. }
  228. else {
  229. normalModeOn(); // Normal mode, blue Power LED is on, all others are off
  230. }
  231. }
  232. while (!successRead); //the program will not go further while you are not getting a successful read
  233. if (programMode) {
  234. if ( isMaster(readCard) ) { //When in program mode check First If master card scanned again to exit program mode
  235. Serial.println(F("Master Card Scanned"));
  236. Serial.println(F("Exiting Program Mode"));
  237. Serial.println(F("-----------------------------"));
  238. programMode = false;
  239. return;
  240. }
  241. else {
  242. if ( findID(readCard) ) { // If scanned card is known delete it
  243. Serial.println(F("I know this PICC, removing..."));
  244. deleteID(readCard);
  245. Serial.println("-----------------------------");
  246. Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
  247. }
  248. else { // If scanned card is not known add it
  249. Serial.println(F("I do not know this PICC, adding..."));
  250. writeID(readCard);
  251. Serial.println(F("-----------------------------"));
  252. Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
  253. }
  254. }
  255. }
  256. else {
  257. if ( isMaster(readCard)) { // If scanned card's ID matches Master Card's ID - enter program mode
  258. programMode = true;
  259. Serial.println(F("Hello Master - Entered Program Mode"));
  260. uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
  261. Serial.print(F("I have ")); // stores the number of ID's in EEPROM
  262. Serial.print(count);
  263. Serial.print(F(" record(s) on EEPROM"));
  264. Serial.println("");
  265. Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
  266. Serial.println(F("Scan Master Card again to Exit Program Mode"));
  267. Serial.println(F("-----------------------------"));
  268. }
  269. else {
  270. if ( findID(readCard) ) { // If not, see if the card is in the EEPROM
  271. Serial.println(F("Welcome, You shall pass"));
  272. granted(300); // Open the door lock for 300 ms
  273. }
  274. else { // If not, show that the ID was not valid
  275. Serial.println(F("You shall not pass"));
  276. denied();
  277. }
  278. }
  279. }
  280. }
  281.  
  282. ///////////////////////////////////////// Access Granted ///////////////////////////////////
  283. void granted ( uint16_t setDelay) {
  284. digitalWrite(blueLed, LED_OFF); // Turn off blue LED
  285. digitalWrite(redLed, LED_OFF); // Turn off red LED
  286. digitalWrite(greenLed, LED_ON); // Turn on green LED
  287. digitalWrite(relay, LOW); // Unlock door!
  288. delay(setDelay); // Hold door lock open for given seconds
  289. digitalWrite(relay, HIGH); // Relock door
  290. delay(1000); // Hold green LED on for a second
  291. }
  292.  
  293. ///////////////////////////////////////// Access Denied ///////////////////////////////////
  294. void denied() {
  295. digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
  296. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  297. digitalWrite(redLed, LED_ON); // Turn on red LED
  298. delay(1000);
  299. }
  300.  
  301.  
  302. ///////////////////////////////////////// Get PICC's UID ///////////////////////////////////
  303. uint8_t getID() {
  304. // Getting ready for Reading PICCs
  305. if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
  306. return 0;
  307. }
  308. if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue
  309. return 0;
  310. }
  311. // There are Mifare PICCs which have 4 byte or 7 byte UID care if you use 7 byte PICC
  312. // I think we should assume every PICC as they have 4 byte UID
  313. // Until we support 7 byte PICCs
  314. Serial.println(F("Scanned PICC's UID:"));
  315. for ( uint8_t i = 0; i < 4; i++) { //
  316. readCard[i] = mfrc522.uid.uidByte[i];
  317. Serial.print(readCard[i], HEX);
  318. }
  319. Serial.println("");
  320. mfrc522.PICC_HaltA(); // Stop reading
  321. return 1;
  322. }
  323.  
  324. void ShowReaderDetails() {
  325. // Get the MFRC522 software version
  326. byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
  327. Serial.print(F("MFRC522 Software Version: 0x"));
  328. Serial.print(v, HEX);
  329. if (v == 0x91)
  330. Serial.print(F(" = v1.0"));
  331. else if (v == 0x92)
  332. Serial.print(F(" = v2.0"));
  333. else
  334. Serial.print(F(" (unknown),probably a chinese clone?"));
  335. Serial.println("");
  336. // When 0x00 or 0xFF is returned, communication probably failed
  337. if ((v == 0x00) || (v == 0xFF)) {
  338. Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
  339. Serial.println(F("SYSTEM HALTED: Check connections."));
  340. // Visualize system is halted
  341. digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
  342. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  343. digitalWrite(redLed, LED_ON); // Turn on red LED
  344. while (true); // do not go further
  345. }
  346. }
  347.  
  348. ///////////////////////////////////////// Cycle Leds (Program Mode) ///////////////////////////////////
  349. void cycleLeds() {
  350. digitalWrite(redLed, LED_OFF); // Make sure red LED is off
  351. digitalWrite(greenLed, LED_ON); // Make sure green LED is on
  352. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  353. delay(200);
  354. digitalWrite(redLed, LED_OFF); // Make sure red LED is off
  355. digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
  356. digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
  357. delay(200);
  358. digitalWrite(redLed, LED_ON); // Make sure red LED is on
  359. digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
  360. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  361. delay(200);
  362. }
  363.  
  364. //////////////////////////////////////// Normal Mode Led ///////////////////////////////////
  365. void normalModeOn () {
  366. digitalWrite(blueLed, LED_ON); // Blue LED ON and ready to read card
  367. digitalWrite(redLed, LED_OFF); // Make sure Red LED is off
  368. digitalWrite(greenLed, LED_OFF); // Make sure Green LED is off
  369. digitalWrite(relay, HIGH); // Make sure Door is Locked
  370. }
  371.  
  372. //////////////////////////////////////// Read an ID from EEPROM //////////////////////////////
  373. void readID( uint8_t number ) {
  374. uint8_t start = (number * 4 ) + 2; // Figure out starting position
  375. for ( uint8_t i = 0; i < 4; i++ ) { // Loop 4 times to get the 4 Bytes
  376. storedCard[i] = EEPROM.read(start + i); // Assign values read from EEPROM to array
  377. }
  378. }
  379.  
  380. ///////////////////////////////////////// Add ID to EEPROM ///////////////////////////////////
  381. void writeID( byte a[] ) {
  382. if ( !findID( a ) ) { // Before we write to the EEPROM, check to see if we have seen this card before!
  383. uint8_t num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards
  384. uint8_t start = ( num * 4 ) + 6; // Figure out where the next slot starts
  385. num++; // Increment the counter by one
  386. EEPROM.write( 0, num ); // Write the new count to the counter
  387. for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times
  388. EEPROM.write( start + j, a[j] ); // Write the array values to EEPROM in the right position
  389. }
  390. successWrite();
  391. Serial.println(F("Succesfully added ID record to EEPROM"));
  392. }
  393. else {
  394. failedWrite();
  395. Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
  396. }
  397. }
  398.  
  399. ///////////////////////////////////////// Remove ID from EEPROM ///////////////////////////////////
  400. void deleteID( byte a[] ) {
  401. if ( !findID( a ) ) { // Before we delete from the EEPROM, check to see if we have this card!
  402. failedWrite(); // If not
  403. Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
  404. }
  405. else {
  406. uint8_t num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards
  407. uint8_t slot; // Figure out the slot number of the card
  408. uint8_t start; // = ( num * 4 ) + 6; // Figure out where the next slot starts
  409. uint8_t looping; // The number of times the loop repeats
  410. uint8_t j;
  411. uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that stores number of cards
  412. slot = findIDSLOT( a ); // Figure out the slot number of the card to delete
  413. start = (slot * 4) + 2;
  414. looping = ((num - slot) * 4);
  415. num--; // Decrement the counter by one
  416. EEPROM.write( 0, num ); // Write the new count to the counter
  417. for ( j = 0; j < looping; j++ ) { // Loop the card shift times
  418. EEPROM.write( start + j, EEPROM.read(start + 4 + j)); // Shift the array values to 4 places earlier in the EEPROM
  419. }
  420. for ( uint8_t k = 0; k < 4; k++ ) { // Shifting loop
  421. EEPROM.write( start + j + k, 0);
  422. }
  423. successDelete();
  424. Serial.println(F("Succesfully removed ID record from EEPROM"));
  425. }
  426. }
  427.  
  428. ///////////////////////////////////////// Check Bytes ///////////////////////////////////
  429. boolean checkTwo ( byte a[], byte b[] ) {
  430. if ( a[0] != 0 ) // Make sure there is something in the array first
  431. match = true; // Assume they match at first
  432. for ( uint8_t k = 0; k < 4; k++ ) { // Loop 4 times
  433. if ( a[k] != b[k] ) // IF a != b then set match = false, one fails, all fail
  434. match = false;
  435. }
  436. if ( match ) { // Check to see if if match is still true
  437. return true; // Return true
  438. }
  439. else {
  440. return false; // Return false
  441. }
  442. }
  443.  
  444. ///////////////////////////////////////// Find Slot ///////////////////////////////////
  445. uint8_t findIDSLOT( byte find[] ) {
  446. uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
  447. for ( uint8_t i = 1; i <= count; i++ ) { // Loop once for each EEPROM entry
  448. readID(i); // Read an ID from EEPROM, it is stored in storedCard[4]
  449. if ( checkTwo( find, storedCard ) ) { // Check to see if the storedCard read from EEPROM
  450. // is the same as the find[] ID card passed
  451. return i; // The slot number of the card
  452. break; // Stop looking we found it
  453. }
  454. }
  455. }
  456.  
  457. ///////////////////////////////////////// Find ID From EEPROM ///////////////////////////////////
  458. boolean findID( byte find[] ) {
  459. uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
  460. for ( uint8_t i = 1; i <= count; i++ ) { // Loop once for each EEPROM entry
  461. readID(i); // Read an ID from EEPROM, it is stored in storedCard[4]
  462. if ( checkTwo( find, storedCard ) ) { // Check to see if the storedCard read from EEPROM
  463. return true;
  464. break; // Stop looking we found it
  465. }
  466. else { // If not, return false
  467. }
  468. }
  469. return false;
  470. }
  471.  
  472. ///////////////////////////////////////// Write Success to EEPROM ///////////////////////////////////
  473. // Flashes the green LED 3 times to indicate a successful write to EEPROM
  474. void successWrite() {
  475. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  476. digitalWrite(redLed, LED_OFF); // Make sure red LED is off
  477. digitalWrite(greenLed, LED_OFF); // Make sure green LED is on
  478. delay(200);
  479. digitalWrite(greenLed, LED_ON); // Make sure green LED is on
  480. delay(200);
  481. digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
  482. delay(200);
  483. digitalWrite(greenLed, LED_ON); // Make sure green LED is on
  484. delay(200);
  485. digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
  486. delay(200);
  487. digitalWrite(greenLed, LED_ON); // Make sure green LED is on
  488. delay(200);
  489. }
  490.  
  491. ///////////////////////////////////////// Write Failed to EEPROM ///////////////////////////////////
  492. // Flashes the red LED 3 times to indicate a failed write to EEPROM
  493. void failedWrite() {
  494. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  495. digitalWrite(redLed, LED_OFF); // Make sure red LED is off
  496. digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
  497. delay(200);
  498. digitalWrite(redLed, LED_ON); // Make sure red LED is on
  499. delay(200);
  500. digitalWrite(redLed, LED_OFF); // Make sure red LED is off
  501. delay(200);
  502. digitalWrite(redLed, LED_ON); // Make sure red LED is on
  503. delay(200);
  504. digitalWrite(redLed, LED_OFF); // Make sure red LED is off
  505. delay(200);
  506. digitalWrite(redLed, LED_ON); // Make sure red LED is on
  507. delay(200);
  508. }
  509.  
  510. ///////////////////////////////////////// Success Remove UID From EEPROM ///////////////////////////////////
  511. // Flashes the blue LED 3 times to indicate a success delete to EEPROM
  512. void successDelete() {
  513. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  514. digitalWrite(redLed, LED_OFF); // Make sure red LED is off
  515. digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
  516. delay(200);
  517. digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
  518. delay(200);
  519. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  520. delay(200);
  521. digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
  522. delay(200);
  523. digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
  524. delay(200);
  525. digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
  526. delay(200);
  527. }
  528.  
  529. ////////////////////// Check readCard IF is masterCard ///////////////////////////////////
  530. // Check to see if the ID passed is the master programing card
  531. boolean isMaster( byte test[] ) {
  532. if ( checkTwo( test, masterCard ) )
  533. return true;
  534. else
  535. return false;
  536. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement