RFID Door Lock Using Arduino Uno(Automation Project )
The RFID Door Lock system is a secure and convenient access control solution that uses RFID technology to allow or deny access to a door. By scanning an RFID card, the system can identify authorized users and trigger a servo motor to unlock the door if access is granted. This technology is widely used in offices, homes, and restricted areas to ensure only authorized personnel can enter.
RFID Door Lock
Description
The RFID Door Lock system is a secure and convenient access
control solution that uses RFID technology to allow or deny access to a door.
By scanning an RFID card, the system can identify authorized users and trigger
a servo motor to unlock the door if access is granted. This technology is
widely used in offices, homes, and restricted areas to ensure only authorized
personnel can enter.
Required Components
- Arduino
Board: The main microcontroller to process the RFID data and control
the servo motor and LEDs.
- RFID
Module (MFRC522): Used to read RFID cards and tags.
- SS
(Slave Select) pin: Pin 10
- RST
(Reset) pin: Pin 9
- Servo
Motor: Controls the locking mechanism of the door.
- LEDs:
Indicate the access status (Red for denied, Green for granted).
- Red
LED: Pin 6
- Green
LED: Pin 5
- Connecting
Wires: For establishing connections between components.
- Power
Supply: Adequate power supply for the Arduino and the RFID module.
Working Principle
- Initialization:
- The
Arduino initializes serial communication for debugging.
- The
RFID module is set up to start scanning for RFID cards.
- The
servo motor and LEDs are configured to their respective pins.
- Card
Scanning:
- The
RFID module continuously scans for RFID cards.
- When
a card is detected, the RFID module reads the card’s serial number and
converts it into a string format.
- Access
Verification:
- The
scanned card number is compared against a list of pre-stored authorized
card numbers.
- If
the card number matches one of the authorized numbers, access is granted.
- If
the card number does not match, access is denied.
- Access
Control:
- If
access is granted, the green LED lights up, and the servo motor moves to
unlock the door.
- The
servo motor then returns to its original position after a delay,
re-locking the door.
- If access
is denied, the red LED lights up, indicating that the card is not
authorized.
Circuit Diagram:
Code:
#include
<RFID.h>
#include
<SPI.h>
#include
<Servo.h>
RFID rfid(10, 9); //
SS, RST PIN
Servo myServo;
int serNum[5];
int RedLED = 6;
int GreenLED = 5;
int ServoPin = 3;
String cardno;
// change below
numbers to your card number later
char *mycards[] =
{"22841931649","0000","13646335144"};
void setup() {
pinMode(RedLED, OUTPUT);
pinMode(GreenLED, OUTPUT);
pinMode(ServoPin, OUTPUT);
myServo.attach(ServoPin);
Serial.begin(9600);
SPI.begin();
rfid.init(); // Function to start the RFID
scan
}
void loop() {
myServo.write(0); // Setting the servo to the
locked position
digitalWrite(RedLED, LOW);
digitalWrite(GreenLED, LOW);
if (rfid.isCard()) { // Loop begins when the
card is scanned
if (rfid.readCardSerial()) {
cardno = ""; // Defining an
empty array to store the card number received
for (int i = 0; i < 5; i++) { //
Iterate through every character of card number and send to cardno variable
cardno += String(rfid.serNum[i]);
}
Serial.print("Card detected:
#");
Serial.println(cardno);
}
int access = 0;
for (int i = 0; i < sizeof(mycards);
i++) {
if (cardno == mycards[i]) { // Matches
the card number received to card number stored within Arduino memory
access = 1;
}
}
if (access == 1) {
accessGranted(); // If card is matched
then servo will move
} else {
accessDenied();
}
}
rfid.halt();
delay(1000);
}
// AccessGranted is
the function executed when the card is matched.
// Servo motor will
open the lock and come back to the original position.
void accessGranted()
{
Serial.println("Access Granted!");
digitalWrite(RedLED, LOW);
digitalWrite(GreenLED, HIGH);
myServo.write(120);
delay(2000); // Change the delay time for
your convenience to keep the lock open
myServo.write(0);
}
void accessDenied() {
Serial.println("Access Denied!");
digitalWrite(RedLED, HIGH);
digitalWrite(GreenLED, LOW);
}
Conclusion
The RFID Door Lock system provides a reliable and secure
method of access control by utilizing RFID technology. The integration of an
Arduino microcontroller with an RFID reader, servo motor, and LEDs ensures that
only authorized users can unlock the door. This system is highly versatile and
can be implemented in various settings where secure access is required. With
further enhancements, such as adding a logging system or integrating with a
network, the functionality and security of the RFID Door Lock system can be
significantly improved.