RFID Door Lock System
Build an RFID-based door access system with Arduino, servo lock, and logging.
Parts List
- Arduino Uno
- MFRC522 RFID Module
- RFID Cards/Tags
- Servo Motor (SG90)
- LEDs (Red, Green)
- Buzzer
Step-by-Step Instructions
Wire RFID Module
Connect the MFRC522 RFID module to the Arduino via the SPI interface. Wire SDA to pin 10, SCK to pin 13, MOSI to pin 11, MISO to pin 12, and RST to pin 9. Connect VCC to 3.3V and GND to ground, taking care not to connect VCC to 5V as this will damage the module.
Mount Servo Lock
Attach the SG90 servo motor to your door frame or lock mechanism using double-sided tape or small screws. Connect the servo horn to the latch bolt so that rotating the servo 90 degrees moves the bolt between locked and unlocked positions. Wire the servo signal pin to Arduino pin 3, VCC to 5V, and GND to ground.
Program Access Logic
Write an Arduino sketch that uses the MFRC522 library to read the UID of any presented RFID card. Store authorized UIDs in an array and compare each scanned card against the whitelist. If the card is recognized, rotate the servo to unlock the door for 5 seconds, illuminate the green LED, and sound a brief buzzer tone to indicate access granted.
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
MFRC522 rfid(10, 9);
Servo lock;
byte authorized[][4] = {{0xA1,0xB2,0xC3,0xD4}};
void setup() {
SPI.begin();
rfid.PCD_Init();
lock.attach(3);
lock.write(0);
pinMode(4, OUTPUT);
pinMode(6, OUTPUT);
}
void loop() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;
bool auth = false;
for (int i = 0; i < 1; i++) {
if (memcmp(rfid.uid.uidByte, authorized[i], 4) == 0) auth = true;
}
if (auth) {
lock.write(90);
digitalWrite(4, HIGH);
tone(6, 1000, 200);
delay(5000);
lock.write(0);
digitalWrite(4, LOW);
}
rfid.PICC_HaltA();
}Add Feedback
Connect a green LED to pin 4 and a red LED to pin 5 to provide visual access status feedback. Wire a buzzer to pin 6 for audible confirmation of successful or denied access attempts. Add a short delay after each scan attempt to prevent rapid re-triggering, and implement a simple lockout that rejects all scans for 10 seconds after three consecutive failed attempts.