Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO RFID Door Lock with Servo Motor and LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO RFID Door Lock with Servo Motor and LCD Display

Smart Door Lock System Documentation

Summary

The Smart Door Lock System is designed to control access through a door using RFID technology. The system comprises an Arduino UNO microcontroller, an RFID-RC522 reader, a Servomotor SG90, and an LCD Display 16x4 with I2C interface. The RFID reader scans tags and communicates with the Arduino to validate entry. Upon successful validation, the Arduino commands the servo motor to unlock the door, and the LCD display shows a welcome message. If the tag is not authorized, the LCD will display an access denied message.

Component List

Arduino UNO

RFID-RC522

Servomotor SG90

LCD Display 16x4 I2C

Wiring Details

Arduino UNO

RFID-RC522

Servomotor SG90

LCD Display 16x4 I2C

Documented Code

/*
 * Smart Door Lock Project
 * This Arduino sketch controls a smart door lock system using an RFID reader,
 * a servo motor, and an LCD display. The RFID reader reads tags, and if the
 * tag is authorized, the servo motor unlocks the door and the LCD displays
 * a welcome message.
 */

#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

#define SS_PIN 10
#define RST_PIN 9
#define SERVO_PIN 3
#define LCD_ADDR 0x27
#define LCD_COLS 16
#define LCD_ROWS 4

MFRC522 rfid(SS_PIN, RST_PIN);
Servo myServo;
LiquidCrystal_I2C lcd(LCD_ADDR, LCD_COLS, LCD_ROWS);

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  myServo.attach(SERVO_PIN);
  myServo.write(0); // Lock position
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Scan your card");
}

void loop() {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
    return;
  }
  String uid = "";
  for (byte i = 0; i < rfid.uid.size; i++) {
    uid += String(rfid.uid.uidByte[i] < 0x10 ? "0" : "");
    uid += String(rfid.uid.uidByte[i], HEX);
  }
  uid.toUpperCase();
  Serial.println(uid);
  if (uid == "YOUR_AUTHORIZED_UID") {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Access Granted");
    myServo.write(90); // Unlock position
    delay(5000); // Keep unlocked for 5 seconds
    myServo.write(0); // Lock position
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Scan your card");
  } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Access Denied");
    delay(2000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Scan your card");
  }
  rfid.PICC_HaltA();
  rfid.PCD_StopCrypto1();
}

This code is responsible for initializing the components, reading RFID tags, controlling the servo motor, and updating the LCD display based on the tag's authorization status.