Arduino: Advanced Methods and Strategies of Using Arduino by Thorpe Ethan

Arduino: Advanced Methods and Strategies of Using Arduino by Thorpe Ethan

Author:Thorpe, Ethan [Thorpe, Ethan]
Language: eng
Format: epub
Published: 2020-02-11T16:00:00+00:00


Setup () and Lopp () Functions

In the void setup () function we do all necessary initializations:

LCD;

Serial port;

mfrc522;

Input and output pins;

In addition, we have already called the StandardMessage () function to display a standard message on the LCD.

In the Void Loop () function, we have two if's that are present in all examples of programs in the MFRC522 .h library . (https://www.arduinolibraries.info/libraries/mfrc522)

In these two if's, specific library functions are called to search for a card in the vicinity of the reader, and select/read that card if present.

After this first step, we call the getUID () function, in which we separate the identification bytes of the card reader into a string named UID. In addition, we present this UID on the serial port.

If you still do not know the UID of your card, the first time you run the program, whenever you bring the card close to the reader, the access denied message will appear, because the UID that is in the program (22 C9 0A 10) is from the card we used to prepare the post.

Just open the serial terminal and bring the card closer to the reader, so the UID of your card will be displayed on the serial terminal, and you can replace the flag CardReleased in the program with your UID.

After loading the program with the updated flag, the message displayed for your card will be “Access Cleared.”

With the UID of the card read, we do an if-else to find out if this UID is the same as the one saved in the program (in the flag CardReleased).

If it is the same, the program displays the message “Access cleared” and triggers two beeps with the buzzer. If it is any other card, the message “Access Denied” is shown, and we trigger four beeps with the Buzzer.

Auxiliary Functions

We have three auxiliary functions, they are;

BuzzerBeeps (int NumberBeeps);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.