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

Arduino UNO RFID Access Control System with LED Indicators and Servo Motor

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

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller interfaced with an RFID-RC522 module, two LEDs (red and green), and a servo motor. The circuit is designed to read RFID cards. When a card is recognized, the green LED lights up, and the servo motor rotates 180 degrees. If the card reading fails, the red LED lights up.

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
  2. RFID-RC522

    • Description: A low-cost RFID module that uses the MFRC522 IC.
    • Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA
  3. LED: Two Pin (red)

    • Description: A standard red LED.
    • Pins: cathode, anode
  4. LED: Two Pin (green)

    • Description: A standard green LED.
    • Pins: cathode, anode
  5. Servo

    • Description: A standard servo motor.
    • Pins: GND, VCC, PWM

Wiring Details

Arduino UNO

RFID-RC522

LED: Two Pin (red)

LED: Two Pin (green)

Servo

Code Documentation

Arduino UNO Code

/*
 * This Arduino sketch initializes the RFID-RC522 module and turns on a green
 * LED when a card is recognized. If the card reading fails, a red LED is
 * turned on. Additionally, when the green LED is turned on, a servo motor
 * rotates 180 degrees.
 */

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

#define RST_PIN 9
#define SS_PIN 10
#define GREEN_LED_PIN 7
#define RED_LED_PIN 8
#define SERVO_PIN 6

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
Servo myServo; // Create Servo instance

void setup() {
  Serial.begin(9600); // Initialize serial communications
  SPI.begin(); // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522
  pinMode(GREEN_LED_PIN, OUTPUT); // Set green LED pin as output
  pinMode(RED_LED_PIN, OUTPUT); // Set red LED pin as output
  digitalWrite(GREEN_LED_PIN, LOW); // Turn off green LED initially
  digitalWrite(RED_LED_PIN, LOW); // Turn off red LED initially
  myServo.attach(SERVO_PIN); // Attach servo to pin
  myServo.write(0); // Initialize servo position to 0 degrees
  Serial.println("Place your card to the reader...");
}

void loop() {
  // Look for new cards
  if (!mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if (!mfrc522.PICC_ReadCardSerial()) {
    Serial.println("Card read failed!");
    digitalWrite(RED_LED_PIN, HIGH);
    delay(1000); // Keep red LED on for 1 second
    digitalWrite(RED_LED_PIN, LOW);
    return;
  }

  // If a card is detected, turn on the green LED and rotate servo
  Serial.println("Card detected!");
  digitalWrite(GREEN_LED_PIN, HIGH);
  myServo.write(180); // Rotate servo to 180 degrees
  delay(1000); // Keep green LED on for 1 second
  digitalWrite(GREEN_LED_PIN, LOW);
  myServo.write(0); // Reset servo to 0 degrees
}

RFID-RC522 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 the components used, their wiring details, and the code running on the microcontroller.