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

Arduino UNO RFID Access Control with LED and Buzzer Indicators

View and Edit Project In Cirkit DesignerImage of Arduino UNO RFID Access Control with LED and Buzzer Indicators

Circuit Documentation

Summary

This circuit is designed to utilize an Arduino UNO as the central microcontroller to interface with an RFID-RC522 module for RFID card reading, control an LED and a buzzer for visual and audible feedback, and use a pushbutton to manually reset the system. The RFID reader checks for authorized tags and activates the LED and buzzer when a match is found. The pushbutton allows for manual deactivation of the LED and buzzer.

Component List

Arduino UNO

RFID-RC522

Buzzer

LED: Two Pin (orange)

Resistor (220 Ohms)

Resistor (10k Ohms)

Pushbutton

Wiring Details

Arduino UNO

RFID-RC522

Buzzer

LED: Two Pin (orange)

Resistor (220 Ohms)

Resistor (10k Ohms)

Pushbutton

Documented Code

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

#define RST_PIN 9     // Reset pin for RFID
#define SS_PIN 10     // SDA/SS pin for RFID
#define LED_PIN 3     // LED connected to pin 3
#define BUZZER_PIN 8  // Buzzer connected to pin 8
#define BUTTON_PIN 4  // Button to turn off LED and buzzer

MFRC522 rfid(SS_PIN, RST_PIN);

boolean isSystemActive = false; // Keeps track if LED and Buzzer are on

// Replace with the UID of your RFID tag (4 bytes)
byte authorizedUID[4] = {0xAB, 0xCD, 0x12, 0x34};

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  
  // Initialize RFID module
  SPI.begin();
  rfid.PCD_Init();
  
  // Set pin modes
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);  // Use internal pull-up resistor for the button
  
  // Start with LED and buzzer off
  digitalWrite(LED_PIN, LOW);
  digitalWrite(BUZZER_PIN, LOW);
}

void loop() {
  // Check if the button is pressed (LOW because of pull-up resistor)
  if (digitalRead(BUTTON_PIN) == LOW && isSystemActive) {
    // Turn off the LED and buzzer manually
    digitalWrite(LED_PIN, LOW);
    digitalWrite(BUZZER_PIN, LOW);
    isSystemActive = false;  // Reset system state
    delay(500);  // Debouncing
  }

  // Look for RFID cards
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
    return;
  }
  
  // Check if the UID matches the authorized one
  if (checkUID(rfid.uid.uidByte)) {
    // Turn on LED and buzzer
    digitalWrite(LED_PIN, HIGH);
    digitalWrite(BUZZER_PIN, HIGH);
    isSystemActive = true;  // Set system to active state
  }

  // Halt the PICC and stop reading
  rfid.PICC_HaltA();
  rfid.PCD_StopCrypto1();
}

// Function to compare the scanned UID with the authorized one
boolean checkUID(byte *uid) {
  for (byte i = 0; i < 4; i++) {
    if (uid[i] != authorizedUID[i]) {
      return false;
    }
  }
  return true;
}

This code is designed to run on the Arduino UNO and interfaces with the RFID-RC522 module to read RFID tags. When an authorized tag is detected, the LED and buzzer are activated. The pushbutton allows the user to reset the system, turning off the LED and buzzer. The code includes setup and loop functions, as well as a helper function checkUID to compare the scanned UID with the authorized one.