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

Arduino UNO RFID Door Lock System with Keypad and Buzzer

View and Edit Project In Cirkit DesignerImage of Arduino UNO RFID Door Lock System with Keypad and Buzzer

Circuit Documentation

Summary

This document provides a detailed overview of a door locking system that utilizes an RFID reader, a membrane matrix keypad, and an Arduino UNO microcontroller. The system allows for the registration of new RFID cards, validation of access using a numeric code, and deletion of registered cards in case of loss. The system also includes a buzzer for audio feedback and LEDs for visual indicators.

Component List

  1. Arduino UNO

    • Description: A 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, Power
  2. RFID-RC522

    • Description: An RFID reader module.
    • Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA
  3. Magnetic Lock

    • Description: An electromagnetic lock.
    • Pins: S, GND
  4. 12V Relay

    • Description: A relay module for switching high voltage devices.
    • Pins: NO, COM, NC, DC+, DC-, IN
  5. LED: Two Pin (Red)

    • Description: A red LED.
    • Pins: Cathode, Anode
  6. LED: Two Pin (Green)

    • Description: A green LED.
    • Pins: Cathode, Anode
  7. Buzzer

    • Description: A piezoelectric buzzer.
    • Pins: PIN, GND
  8. Membrane Matrix Keypad

    • Description: A 4x3 matrix keypad.
    • Pins: Row 1, Row 2, Row 3, Row 4, Column 1, Column 2, Column 3
  9. PC817 Optotransistor

    • Description: An optocoupler.
    • Pins: Anode, Cathode, Collector, Emitter
  10. 12V Power Supply

    • Description: A 12V DC power supply.
    • Pins: +, -
  11. XL6009 Voltage Regulator

    • Description: A DC-DC step-up voltage regulator.
    • Pins: OUT +, OUT -, IN +, IN -

Wiring Details

Arduino UNO

RFID-RC522

Magnetic Lock

12V Relay

LED: Two Pin (Red)

LED: Two Pin (Green)

Buzzer

Membrane Matrix Keypad

PC817 Optotransistor

12V Power Supply

XL6009 Voltage Regulator

Documented Code

/*
 * Ce sketch Arduino contrôle un système de verrouillage de porte utilisant RFID
 * et un clavier matriciel. Le système permet d'enregistrer de nouvelles cartes
 * RFID, de valider l'accès avec un code numérique, et de supprimer des cartes
 * enregistrées en cas de perte. Un buzzer émet des sons différents pour les
 * actions de validation et d'enregistrement.
 */

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

#define RST_PIN 9
#define SS_PIN 10
#define RED_LED_PIN 5
#define GREEN_LED_PIN 4
#define RELAY_PIN 3
#define BUZZER_PIN 2
#define MAX_ATTEMPTS 5
#define ADDITIONAL_ATTEMPTS 3
#define ALARM_DURATION 60000 // 1 minute in milliseconds
#define LOCK_DURATION 3600000 // 1 hour in milliseconds

MFRC522 mfrc522(SS_PIN, RST_PIN);

const byte ROWS = 4; // four rows
const byte COLS = 3; // three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {7, A5, A4, A3};
byte colPins[COLS] = {A2, A1, A0};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

byte authorizedUIDs[10][4];
int numAuthorizedUIDs = 0;

int failedAttempts = 0;
int additionalFailedAttempts = 0;
bool isLocked = false;
unsigned long lockStartTime = 0;

void setup() {
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
  pinMode(RED_LED_PIN, OUTPUT);
  pinMode(GREEN_LED_PIN, OUTPUT);
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  digitalWrite(RE