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

Arduino Mega 2560-Based RFID Access Control System with LCD Display and Buzzer

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based RFID Access Control System with LCD Display and Buzzer

Circuit Documentation

Summary

This circuit is designed to control access using RFID cards, an LCD display, and solenoids. It includes an Arduino Mega 2560 microcontroller, RFID reader, LCD display, relays, solenoids, inductive sensors, and a buzzer. The system allows authorized users to unlock doors using RFID cards and provides feedback via the LCD and buzzer.

Component List

  1. 1-Channel Relay (5V 10A)

    • Pins: NC, signal, C, power, NO, ground
    • Description: Used to control high-power devices like solenoids.
  2. Inductive Sensor

    • Pins: Signal, VCC, GND
    • Description: Detects the presence of metal objects.
  3. Solenoid

    • Pins: pin1, pin2
    • Description: Electromechanical device used to lock/unlock doors.
  4. 12V Power Supply

    • Pins: +, -
    • Description: Provides 12V power to the circuit.
  5. RFID-RC522

    • Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA
    • Description: RFID reader module for reading RFID cards.
  6. LCD I2C

    • Pins: GND, VCC, SDA, SCL
    • Description: LCD display with I2C interface for displaying messages.
  7. Arduino Mega 2560

    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
    • Description: Microcontroller used to control the entire system.
  8. Buzzer

    • Pins: PIN, GND
    • Description: Provides audible feedback.

Wiring Details

1-Channel Relay (5V 10A)

Inductive Sensor

Solenoid

12V Power Supply

RFID-RC522

LCD I2C

Arduino Mega 2560

Buzzer

Code Documentation

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

// Pin Definitions
#define RST_PIN 9
#define SS_PIN 53
#define BUZZER_PIN 8
#define SOLENOID1_PIN 7
#define SOLENOID2_PIN 6
#define PROX_SENSOR1_PIN 5
#define PROX_SENSOR2_PIN 4

// RFID Master and Teacher Cards
#define MASTER_CARD_1 "BD9DCD2C" //VALLE
#define MASTER_CARD_2 "7D61D02C" //IGNACIO
#define MASTER_CARD_3 "" //CARDENAS CDB2CF7A
#define TEACHER_CARD_1 "5B83A70D" //RFID TAG
#define TEACHER_CARD_2 "2333911B" //RFID CARD

// Initialize LCD with I2C
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Initialize RFID Reader
MFRC522 mfrc522(SS_PIN, RST_PIN);

// Global variables
long countdownTime = 180 * 60;  // 180 minutes in seconds
bool doorOpen = false;

void setup() {
  // Initialize Serial communication
  Serial.begin(9600);

  // Initialize LCD
  lcd.init();
  lcd.backlight();

  // Initialize RFID
  SPI.begin();
  mfrc522.PCD_Init();

  // Initialize pins
  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(SOLENOID1_PIN, OUTPUT);
  pinMode(SOLENOID2_PIN, OUTPUT);
  pinMode(PROX_SENSOR1_PIN, INPUT);
  pinMode(PROX_SENSOR2_PIN, INPUT);

  // Initial state
  closeSolenoids();
  updateLCD("  Tap card here  ");
}

void loop() {
  // Check for forced door open
  if ((!digitalRead(PROX_SENSOR1_PIN) && !digitalRead(PROX_SENSOR2_PIN)) && !doorOpen) {
    unauthorizedAccess();
  }

  // Check for RFID card presence
  if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
    String cardUID = "";
    for (byte i = 0; i < mfrc522.uid.size; i++) {
      cardUID += String(mfrc522