Multi-Factor Access: RFID and Bluetooth Synergy
Traditional locks are susceptible to picking, but the RFID Two-Card Door Lock introduces a digital fail-safe. This project utilizes the Arduino Mega 2560 to manage a dual-input security system: a physical MFRC522 RFID Reader for on-site access and an HC-05 Bluetooth Module for remote smartphone control. By requiring specific digital "Keys," this system ensures that only authorized users can actuate the heavy-duty door mechanism.
Two-Card Authentication Logic
The "Two-Card" feature adds an extra layer of security similar to a bank vault:
- Sequential Scans: The Arduino can be programmed to require two different cards to be scanned within a specific time window (e.g., 5 seconds). This "Dual-Key" setup ensures that a single lost card isn't enough to compromise the premises.
- Whitelist Management: The project utilizes the MFRC522.h library to read the unique UID of each RFID tag. These UIDs are compared against a hard-coded or EEPROM-stored whitelist. If the UID matches, the Arduino grants a "Partial Success" state until the second card is verified.
- Visual Indication: The system typically uses LEDs (Red/Green) or a buzzer to provide feedback on each scan, guiding the user through the two-step process.
Mechanical Drive: L298N and DC Motors
Unlike a simple solenoid, this project uses a high-torque DC Motor driven by an L298N Dual H-Bridge:
- Reversible Direction: The L298N allows the Arduino to spin the motor forward to "Unlock" and reverse to "Lock" the door.
- Current Isolation: Because motors generate electrical "Noise" and back-EMF, the L298N isolates the sensitive Arduino Mega from the high-current demands of the lock motor.
- Variable Torque: Using PWM (Pulse Width Modulation), the developer can adjust the speed of the motor to ensure the lock closes softly but firmly.
Wireless Override: The Bluetooth Bridge
For convenience, the HC-05 Bluetooth Module serves as a digital override. Using a standard "Serial Bluetooth Terminal" app on a smartphone, the user can send a secret string (e.g., "OPEN_SESAME"). The Arduino parses this incoming serial data and triggers the L298N driver instantly, allowing for "Keyless Entry" without needing a physical RFID card.
Wiring for the Mega 2560
The Arduino Mega is chosen for its abundant SPI and Serial pins:
- SPI Pins: The MFRC522 requires pins 50 (MISO), 51 (MOSI), 52 (SCK), and 53 (SDA/SS).
- Serial1: The HC-05 is connected to the Mega's second hardware serial port (TX1/RX1), allowing for reliable wireless communication without interfering with the main USB debugging line.
schmatics

* -----------------------------------------------------------------------------------------
* 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
*/