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

Arduino Mega 2560 Controlled RFID Access System with Servo and LCD Feedback

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Controlled RFID Access System with Servo and LCD Feedback

Circuit Documentation

Summary

This circuit integrates various components controlled by an Arduino Mega 2560 microcontroller to perform tasks involving an LCD display, a servo motor, an RFID reader, and LED indicators. The Arduino Mega 2560 is the central processing unit that interfaces with an I2C LCD display for user feedback, a Tower Pro SG90 servo for mechanical movements, an RFID-RC522 module for RFID card scanning, and LEDs for visual signaling. The circuit is designed to scan RFID cards, display messages on the LCD, and actuate the servo motor based on the card scans.

Component List

Arduino Mega 2560

Tower Pro SG90 Servo

LCD I2C Display

RFID-RC522

LED: Four Pin (Common Cathode)

Resistor (200 Ohms)

Resistor (320 Ohms)

Wiring Details

Arduino Mega 2560

Tower Pro SG90 Servo

LCD I2C Display

RFID-RC522

LED: Four Pin (Common Cathode)

Resistor (200 Ohms)

Resistor (320 Ohms)

Documented Code

#include <Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <MFRC522.h>

// Define pin numbers
#define GREEN_LED_PIN 22
#define RED_LED_PIN 23
#define SERVO_PIN 10
#define RST_PIN 5 
#define SS_PIN 53 

Servo myServo;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address to 0x27 for a 16 chars and 2 line display
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance

void setup() {
  // Set pin modes
  pinMode(GREEN_LED_PIN, OUTPUT);
  pinMode(RED_LED_PIN, OUTPUT);

  // Initialize the servo, LCD, and RFID reader
  myServo.attach(SERVO_PIN);
  lcd.begin();
  SPI.begin();
  mfrc522.PCD_Init();

  // Start with green LED on, servo at 0 degrees
  digitalWrite(GREEN_LED_PIN, HIGH);
  myServo.write(0);

  // Display initial message on LCD
  lcd.clear();
  lcd.print("Scan your card");
}

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

  // Turn off green LED and move servo to 90 degrees
  digitalWrite(GREEN_LED_PIN, LOW);
  myServo.write(90);

  // Display seat assignment on LCD
  lcd.clear();
  lcd.print("Assign to seat 1");

  // Hold the position and wait
  delay(3000); // Hold for 3 seconds before allowing another scan
}

This code is designed to run on the Arduino Mega 2560 and controls the servo, LCD, and RFID reader. It sets up the necessary pins, initializes the peripherals, and enters a loop where it waits for an RFID card to be scanned. Upon scanning a card, it turns off the green LED, moves the servo to 90 degrees, and displays a message on the LCD. After a delay, it resets to wait for another card scan.