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

Arduino RFID Door Lock System with LCD Display and Servo Motor

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

Circuit Documentation

Summary

This circuit is an RFID-based door lock system using an Arduino UNO. The system includes an RFID reader, an LCD display, a servo motor for locking and unlocking, LEDs for status indication, and a buzzer for alerting invalid access. The Arduino UNO controls all components and processes the RFID tags to determine access.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LED: Two Pin (red)

    • Description: Red LED.
    • Pins: cathode, anode
  3. LED: Two Pin (blue)

    • Description: Blue LED.
    • Pins: cathode, anode
  4. LED: Two Pin (green)

    • Description: Green LED.
    • Pins: cathode, anode
  5. Resistor (220 Ohms)

    • Description: Resistor with 220 Ohms resistance.
    • Pins: pin1, pin2
  6. Servo

    • Description: Servo motor for locking and unlocking.
    • Pins: gnd, vcc, pulse
  7. 16x2 I2C LCD

    • Description: 16x2 character LCD with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  8. RFID-RC522

    • Description: RFID reader module.
    • Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA
  9. Buzzer

    • Description: Buzzer for alerting invalid access.
    • Pins: PIN, GND

Wiring Details

Arduino UNO

LED: Two Pin (red)

LED: Two Pin (blue)

LED: Two Pin (green)

Resistor (220 Ohms)

Servo

16x2 I2C LCD

RFID-RC522

Buzzer

Code Documentation

Sketch.ino

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9
#define SS_PIN  10

MFRC522 mfrc522(SS_PIN, RST_PIN);
String UIDCard = "";

void setup() {
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
  Serial.println("Scan your RFID Card:");
  for (int i = 0; i < 20; i++) {
    Serial.print(".");
    delay(50);
  }
  Serial.println("");
}

void loop() {
  while (getUID()) {
    Serial.print("UID: ");
    Serial.println(UIDCard);

    for (int i = 0; i < 20; i++) {
      Serial.print(".");
      delay(50);
    }
    delay(3000);
  }
}

boolean getUID() {
  if (!mfrc522.PICC_IsNewCardPresent()) {
    return false;
  }

  if (!mfrc522.PICC_ReadCardSerial()) {
    return false;
  }
  UIDCard = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    UIDCard.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    UIDCard.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  UIDCard.toUpperCase();
  UIDCard = UIDCard.substring(1);

  mfrc522.PICC_HaltA();
  return true;
}

master.cpp

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9
#define SS_PIN  10

MFRC522 mfrc522(SS_PIN, RST_PIN);
String UIDCard = "";

void setup() {
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
  Serial.println("Scan your RFID Card:");
  for (int i = 0; i < 20; i++) {
    Serial.print(".");
    delay(50);
  }
  Serial.println("");
}

void loop() {
  while (getUID()) {
    Serial.print("UID: ");
    Serial.println(UIDCard);

    for (int i = 0; i < 20; i++) {
      Serial.print(".");
      delay(50);
    }
    delay(3000);
  }
}

boolean getUID() {
  if (!mfrc522.PICC_IsNewCardPresent()) {
    return false;
  }

  if (!mfrc522.PICC_ReadCardSerial()) {
    return false;
  }
  UIDCard = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    UIDCard.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    UIDCard.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  UIDCard.toUpperCase();
  UIDCard = UIDCard.substring(1);

  mfrc522.PICC_HaltA();
  return true;
}

door.cpp

/*
 * Arduino RFID Door Lock
 * Components: RFID-RC522, LCD, Buzzer, Red LED, Blue LED, Green LED,
 * 3x 220 Ohm Resistors, Arduino UNO, Servo Motor
 *
 * This code controls an RFID-based door lock system. When a valid RFID tag
 * is detected, the servo motor unlocks the door, the green LED lights up,
 * and a message is displayed on the LCD. If an invalid tag is detected,
 * the red LED lights up and the buzzer sounds. The blue LED indicates
 * system readiness.
 */

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

#define SS_PIN 10
#define RST_PIN 9