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

Arduino Nano-Based Smart Servo Control System with IR and RFID Sensors

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Smart Servo Control System with IR and RFID Sensors

Circuit Documentation

Summary

This circuit is designed to control a servo motor based on input from an IR sensor and an RFID module. When the IR sensor detects an object, the servo motor rotates to 90 degrees. When an RFID tag is read, the servo motor returns to 0 degrees. Additionally, a buzzer will sound when the IR sensor is triggered, and an I2C LCD will display messages based on the sensor and RFID status. The entire system is controlled by an Arduino Nano microcontroller.

Component List

  1. IR Sensor

    • Pins: out, gnd, vcc
    • Description: Detects the presence of an object.
    • Purpose in Circuit: Triggers the servo motor and buzzer when an object is detected.
  2. MG90S Servo Motor

    • Pins: SIG, VCC, GND
    • Description: A small servo motor.
    • Purpose in Circuit: Rotates to specified angles based on sensor inputs.
  3. Buzzer

    • Pins: PIN, GND
    • Description: Emits sound when activated.
    • Purpose in Circuit: Sounds an alert when the IR sensor is triggered.
  4. 16x2 I2C LCD

    • Pins: GND, VCC, SDA, SCL
    • Description: A 16x2 character LCD with I2C interface.
    • Purpose in Circuit: Displays messages based on sensor and RFID status.
  5. EM-18 RFID Module

    • Pins: TX, VCC, GND
    • Description: Reads RFID tags.
    • Purpose in Circuit: Provides RFID tag data to the microcontroller.
  6. Arduino Nano

    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
    • Description: A small, complete, and breadboard-friendly microcontroller board.
    • Purpose in Circuit: Controls all components and processes sensor inputs.

Wiring Details

IR Sensor

MG90S Servo Motor

Buzzer

16x2 I2C LCD

EM-18 RFID Module

Arduino Nano

Code Documentation

/*
 * This Arduino sketch controls a servo motor based on input from an IR sensor
 * and an RFID module. When the IR sensor detects an object, the servo motor
 * rotates to 90 degrees. When an RFID tag is read, the servo motor returns to
 * 0 degrees. Additionally, a buzzer will sound when the IR sensor is triggered,
 * and an I2C LCD will display messages based on the sensor and RFID status.
 */

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

// Pin definitions
const int irSensorPin = 8;
const int servoPin = 6;
const int buzzerPin = 7;
const int rfidRxPin = 0;

// Servo object
Servo myServo;

// LCD object
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize IR sensor pin
  pinMode(irSensorPin, INPUT);

  // Initialize buzzer pin
  pinMode(buzzerPin, OUTPUT);

  // Attach servo to pin
  myServo.attach(servoPin);
  myServo.write(0); // Start at 0 degrees

  // Initialize LCD
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("System Ready");
}

void loop() {
  // Read IR sensor
  int irValue = digitalRead(irSensorPin);

  if (irValue == HIGH) {
    // IR sensor triggered
    myServo.write(90); // Move servo to 90 degrees
    digitalWrite(buzzerPin, HIGH); // Turn on buzzer
    lcd.setCursor(0, 1);
    lcd.print("IR Detected");
  } else {
    digitalWrite(buzzerPin, LOW); // Turn off buzzer
  }

  // Check for RFID input
  if (Serial.available() > 0) {
    String rfidTag = Serial.readString();
    myServo.write(0); // Move servo to 0 degrees
    lcd.setCursor(0, 1);
    lcd.print("RFID Read");
  }

  delay(100); // Small delay to debounce sensors
}

This code initializes the IR sensor, servo motor, buzzer, and I2C LCD. In the loop function, it continuously checks the IR sensor and RFID module for input. When the IR sensor is triggered, the servo motor moves to 90 degrees, the buzzer sounds, and the LCD displays "IR Detected". When an RFID tag is read, the servo motor returns to 0 degrees, and the LCD displays "RFID Read".