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

Arduino UNO RFID Door Lock System with LCD Feedback and MP3 Audio Prompts

View and Edit Project In Cirkit DesignerImage of Arduino UNO RFID Door Lock System with LCD Feedback and MP3 Audio Prompts

Circuit Documentation

Summary

This circuit is designed to control access through a door using RFID technology. It features an Arduino UNO microcontroller interfaced with an RFID-RC522 module for scanning RFID tags, a DFPlayer MINI for audio feedback, a micro servo motor for actuating the door lock, an LCD screen for displaying system status, and a loudspeaker for audio output. The system operates by scanning RFID tags, providing visual and audio feedback, and controlling a servo motor to lock or unlock the door based on the tag's authorization.

Component List

DFPlayer MINI

Arduino UNO

RFID-RC522

Micro servo 9G

LCD screen 16x2 I2C

Loudspeaker

Wiring Details

DFPlayer MINI

Arduino UNO

RFID-RC522

Micro servo 9G

LCD screen 16x2 I2C

Loudspeaker

Documented Code

#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <DFRobotDFPlayerMini.h>
#include <SoftwareSerial.h>

// Pin Definitions
#define SS_PIN 10           // Slave Select pin for RFID
#define RST_PIN 9           // Reset pin for RFID
#define SERVO_PIN 3         // Pin for controlling the servo motor

// Initialize RFID, Servo, LCD, and MP3 player
MFRC522 rfid(SS_PIN, RST_PIN);            // Create RFID object
Servo myservo;                            // Create Servo object
LiquidCrystal_I2C lcd(0x27, 16, 2);       // Set LCD address (0x27 is common for 16x2 displays)
SoftwareSerial mp3Serial(8, 7);           // Initialize MP3 serial (TX to pin 8, RX to pin 7)
DFRobotDFPlayerMini mp3;                  // Create MP3 player object

void setup() {
  Serial.begin(9600);                     // Start serial communication for debugging

  // Initialize RFID module
  SPI.begin();                            // Begin SPI communication
  rfid.PCD_Init();                        // Initialize RFID reader

  // Initialize LCD display
  lcd.begin(16, 2);                       // Start the LCD (16x2)
  lcd.backlight();                        // Turn on the LCD backlight
  lcd.print("Door System Ready");         // Display initial message

  // Initialize MP3 player
  mp3Serial.begin(9600);                  // Begin communication with MP3 player
  if (!mp3.begin(mp3Serial)) {            // Check if MP3 player initializes successfully
    Serial.println("MP3 player initialization failed!");
    lcd.clear();
    lcd.print("MP3 Init Failed");
  } else {
    Serial.println("MP3 player initialized successfully.");
    mp3.volume(30);                       // Set volume level (0-30)
    mp3.play(4);                          // Play "Door System Ready" sound (0004.mp3)
  }

  // Initialize Servo
  myservo.attach(SERVO_PIN);              // Attach servo to the specified pin
  myservo.write(0);                       // Initial position (door closed)

  delay(1000);                            // Wait for a moment to ensure everything is ready
}

void loop() {
  // Check if a new card is present and read it
  if (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) {
    mp3.volume(30);
    mp3.play(1);                          // Play scanning sound (0001.mp3)

    lcd.clear();
    lcd.print("Scanning...");
    delay(2000);                          // Delay to simulate scanning process

    // Read the UID of the scanned card
    String uid = "";
    for (byte i = 0; i < rfid.uid.size; i++) {
      uid += String(rfid.uid.uidByte[i], HEX); // Append each byte of UID as a hex string
    }

    Serial.print("UID of the card: ");
    Serial.println(uid);                  // Print the UID to the serial monitor for debugging

    // Check if the UID matches the authorized card
    if (uid == "b376c3e4") {              // Replace with your own RFID card UID
      openDoor();                         // Call function to open the door
    } else {
      accessDenied();                     // Call function to handle unauthorized access
    }

    // Stop reading and halt the card communication
    rfid.PICC_HaltA();
    rfid.PCD_StopCrypto1();
    delay(500);                           // Small delay to prevent immediate re-triggering