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

Arduino RFID Door Control System with Servo Motor

View and Edit Project In Cirkit DesignerImage of Arduino RFID Door Control System with Servo Motor

RFID Door Control System Documentation

Summary

This document provides a detailed overview of an RFID Door Control System. The system uses an RFID-RC522 module to read RFID tags. If an authorized tag is detected, a servo motor is activated to open a door. The system is controlled by an Arduino UNO microcontroller, and it also includes an I2C display for visual feedback. Power is supplied by a 9V battery.

Component List

  1. Servo

    • Description: A servo motor used to open and close the door.
    • Pins: gnd, vcc, pulse
  2. RFID-RC522

    • Description: An RFID reader module used to read RFID tags.
    • Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA
  3. Arduino UNO

    • Description: A microcontroller board used to control the system.
    • 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
  4. I2C Display

    • Description: A display module used to provide visual feedback.
    • Pins: GND, VCC, SDL, SCL
  5. 9V Battery

    • Description: A battery used to power the system.
    • Pins: -, +

Wiring Details

Servo

RFID-RC522

Arduino UNO

I2C Display

9V Battery

Code Documentation

/*
 * RFID Door Control System
 * This code reads an RFID tag using the RFID-RC522 module. If the tag is 
 * authorized, it opens the door by rotating a servo motor. If the tag is not 
 * authorized, the door remains closed.
 */

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

#define SS_PIN 10
#define RST_PIN 9
#define SERVO_PIN 3

MFRC522 rfid(SS_PIN, RST_PIN);
Servo doorServo;

// List of authorized RFID tag UIDs
const byte authorizedUID[4] = {0xDE, 0xAD, 0xBE, 0xEF};

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  doorServo.attach(SERVO_PIN);
  doorServo.write(0); // Door closed position
  Serial.println("RFID Door Control System Initialized");
}

void loop() {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
    return;
  }

  if (isAuthorized(rfid.uid.uidByte)) {
    Serial.println("Authorized tag detected. Opening door...");
    doorServo.write(90); // Open door
    delay(5000); // Keep door open for 5 seconds
    doorServo.write(0); // Close door
  } else {
    Serial.println("Unauthorized tag detected. Access denied.");
  }

  rfid.PICC_HaltA();
  rfid.PCD_StopCrypto1();
}

bool isAuthorized(byte *uid) {
  for (byte i = 0; i < 4; i++) {
    if (uid[i] != authorizedUID[i]) {
      return false;
    }
  }
  return true;
}

This code initializes the RFID reader and the servo motor. It continuously checks for new RFID tags. If an authorized tag is detected, the servo motor rotates to open the door for 5 seconds before closing it again. Unauthorized tags are denied access.