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

Arduino RFID Access Control System with Servo Motor

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

Circuit Documentation

Summary

This circuit integrates an RFID reader (RFID-RC522) with an Arduino UNO to control a servo motor. The RFID reader reads RFID tags, and based on the tag's UID, the Arduino controls the servo motor to grant or deny access.

Component List

RFID-RC522

Arduino UNO

Servo

Wiring Details

RFID-RC522

Arduino UNO

Servo

Code Documentation

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

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance
Servo m;

void setup() {
  m.attach(6);
  Serial.begin(9600);   // Initialize serial communication
  SPI.begin();          // Initialize SPI bus
  mfrc522.PCD_Init();   // Initialize MFRC522
  Serial.println("Place your card for reading...");
  Serial.println();
}

void loop() {
  // Look for new cards
  if (!mfrc522.PICC_IsNewCardPresent()) {
    return;
  }
  // Select one of the cards
  if (!mfrc522.PICC_ReadCardSerial()) {
    return;
  }
  // Show UID on Serial Monitor
  Serial.print("UID tag :");
  String content = "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "AE B0 24 D9") { // Change here the UID of the cards you want to grant access
    Serial.println("Access Granted");
    m.write(180);
    delay(5000);
    m.write(0);
  }

  if (content.substring(1) == "30 86 55 A8") { // Change here the UID of the cards you want to grant access
    Serial.println("Access Granted");
    m.write(180);
    delay(5000);
    m.write(0);
  }
}

This code initializes the RFID reader and the servo motor. When an RFID tag is detected, the UID is read and compared against predefined UIDs. If a match is found, the servo motor is activated to grant access.