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

Arduino RFID Access Control System with Servo Lock and LED Indicators

View and Edit Project In Cirkit DesignerImage of Arduino RFID Access Control System with Servo Lock and LED Indicators

Circuit Documentation

Summary

This circuit is an RFID-based access control system using an Arduino UNO. It includes an RFID reader to scan tags, a servo motor to lock/unlock a mechanism, and two LEDs (red and green) to indicate access status. The system checks if the scanned RFID tag matches a predefined authorized tag.

Component List

  1. LED: Two Pin (red)

    • Description: A red LED used to indicate access denial.
    • Pins: Cathode, Anode
  2. Arduino UNO

    • Description: The main microcontroller used to control the circuit.
    • 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
  3. Servo

    • Description: A servo motor used to lock/unlock the mechanism.
    • Pins: GND, VCC, Pulse
  4. Resistor (200 Ohms)

    • Description: A resistor used to limit current.
    • Pins: Pin1, Pin2
    • Properties: Resistance: 200 Ohms
  5. LED: Two Pin (green)

    • Description: A green LED used to indicate access granted.
    • Pins: Cathode, Anode
  6. RFID-RC522

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

    • Description: Ground connection.
    • Pins: GND

Wiring Details

LED: Two Pin (red)

Arduino UNO

Servo

Resistor (200 Ohms)

LED: Two Pin (green)

RFID-RC522

GND

Code Documentation

Arduino UNO Code

/*
 * This Arduino sketch controls an RFID-based access system.
 * It uses an RFID reader to scan tags and a servo motor to
 * lock/unlock a mechanism. Green and red LEDs indicate access
 * status. The system checks if the scanned RFID tag matches
 * a predefined authorized tag.
 */

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

#define RST_PIN 9
#define SS_PIN 10

MFRC522 rfid(SS_PIN, RST_PIN);
Servo serrure;

String tagAutorise = "AB CD EF 12"; // Replace with your tag UID

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  serrure.attach(6); // Servo pin
  serrure.write(0);  // Lock

  pinMode(7, OUTPUT); // Green LED
  pinMode(8, OUTPUT); // Red LED
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);

  Serial.println("Ready to scan a tag.");
}

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

  String uid = "";
  for (byte i = 0; i < rfid.uid.size; i++) {
    uid += String(rfid.uid.uidByte[i], HEX);
    if (i < rfid.uid.size - 1) uid += " ";
  }
  uid.toUpperCase();
  Serial.println("UID tag: " + uid);

  if (uid == tagAutorise) {
    digitalWrite(7, HIGH); // Green LED on
    digitalWrite(8, LOW);  // Red LED off
    Serial.println("Access granted!");
    serrure.write(90); // Unlock
    delay(5000);       // Wait before locking
    serrure.write(0);  // Lock
  } else {
    digitalWrite(7, LOW);  // Green LED off
    digitalWrite(8, HIGH); // Red LED on
    Serial.println("Access denied!");
    delay(2000);
  }

  rfid.PICC_HaltA();
}

GND Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This documentation provides a comprehensive overview of the circuit, including a summary, component list, wiring details, and the code used in the Arduino UNO.