In this post I’ll show you how to build a RFID reader for security access based on Arduino MEGA board. The code I’ve used is a modified version of a design that was published at Arduino project hub. I added 2×16 LCD display to show card ID and MOSFET driver for controlling an electric strike and slightly modified the code to open the lock for 5 sec if a valid card is read by RFID reader. In the next figure you can see the schematic diagram of this project.
In order for this design to work correctly with new RFID card you’ll need to do the following: Upload the attached sketch to Arduino MEGA or compatible board. Place you card near the reader and see its ID on the LCD display. Change the XX XX XX XX field in the code to your card value. Comment out lcd.print(mfrc522.uid.uidByte[i],HEX) line compile and upload the code again. Now the circuit will respond only to a new card ID.
Probably the better way to store card ID is to use Arduino EEPROM memory instead of updating the code each time the card has been changed. I may add this feature in the next version. You can see how the prototype works in a short video next.