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

Arduino Mega 2560 RFID Servo Control System with LCD Feedback

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

Circuit Documentation

Summary of the Circuit

This circuit is designed to interface an Arduino Mega 2560 with an RFID-RC522 module, a Tower Pro SG90 servo motor, and an LCD I2C display. The Arduino Mega 2560 serves as the central processing unit, controlling the servo motor based on RFID card detection and communicating with the LCD display via the I2C protocol. The RFID-RC522 module reads RFID cards and communicates with the Arduino over the SPI interface. The servo motor is controlled through one of the PWM-capable digital pins on the Arduino. The LCD display is used to provide visual feedback and is connected via the I2C bus.

Component List

Tower Pro SG90 Servo

LCD I2C Display

Arduino Mega 2560

RFID-RC522

Wiring Details

Tower Pro SG90 Servo

LCD I2C Display

RFID-RC522

Documented Code

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

#define SS_PIN 53
#define RST_PIN 5
#define SERVO_PIN 10

MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the RFID-RC522 class
Servo myServo; // Instance of the Servo class

void setup() {
  Serial.begin(9600); // Start serial communication at 9600 baud
  SPI.begin(); // Initialize SPI bus
  rfid.PCD_Init();  // Initialize the MFRC522 reader
  myServo.attach(SERVO_PIN);  // Attach the servo to pin 10
  myServo.write(0);  // Start with the servo at 0 degrees
  Serial.println("Place your RFID card near the reader...");
}

void loop() {
  // Look for new cards
  if (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) {
    Serial.print("Card UID: ");
    for (byte i = 0; i < rfid.uid.size; i++) {
      Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
      Serial.print(rfid.uid.uidByte[i], HEX);
    }
    Serial.println();

    // Display message for successful scan
    Serial.println("RC522 RFID Access Control");

    // Rotate the servo to 90 degrees
    myServo.write(90);
    delay(1000);  // Keep the servo at 90 degrees for 1 second

    // Reset the servo back to 0 degrees
    myServo.write(0);

    delay(2000);  // Delay to allow time between readings
  }

  // Stop reading the card
  rfid.PICC_HaltA();
}

This code initializes the RFID-RC522 module and the servo motor, and sets up the Arduino to read RFID cards. When a card is detected, it prints the card's UID to the serial monitor, rotates the servo to 90 degrees, then resets it back to 0 degrees after a short delay.