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

Arduino UNO-Based Light-Activated Servo Control System with LDR Sensor and Battery Power

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Light-Activated Servo Control System with LDR Sensor and Battery Power

Circuit Documentation

Summary

This circuit is designed to control six servo motors based on the input from an LDR (Light Dependent Resistor) sensor using an Arduino UNO. When the LDR sensor detects light, all six servo motors move to 90 degrees. When the LDR sensor stops detecting light, the servos return to 0 degrees. The circuit is powered by a 18650 battery through a Step Up Boost Power Converter to provide a stable 5V supply.

Component List

  1. Arduino UNO

    • Description: 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. Module LDR

    • Description: Light Dependent Resistor module for detecting light intensity.
    • Pins: VCC, GND, DO, AO
  3. Micro servo 9G

    • Description: Small servo motor for precise control of angular position.
    • Pins: GND, +5V, PWM
  4. Battery 18650

    • Description: Rechargeable lithium-ion battery.
    • Pins: +, -
  5. Step Up Boost Power Converter, Adjustable Voltage Regulator

    • Description: Boost converter to step up the voltage from the battery to a stable 5V.
    • Pins: VOUT+, VOUT-, VIN+, VIN-

Wiring Details

Arduino UNO

Module LDR

Micro servo 9G

Battery 18650

Step Up Boost Power Converter, Adjustable Voltage Regulator

Code Documentation

/*
 * This Arduino Sketch controls 6 servo motors based on the input from an LDR sensor.
 * When the LDR sensor detects light, all 6 servo motors move to 90 degrees.
 * When the LDR sensor stops detecting light, the servos return to 0 degrees.
 */

#include <Servo.h>

// Define servo objects
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

// Define pin connections
const int ldrDigitalPin = 7;
const int ldrAnalogPin = A0;
const int servoPin1 = 13;
const int servoPin2 = 12;
const int servoPin3 = 11;
const int servoPin4 = 10;
const int servoPin5 = 9;
const int servoPin6 = 8;

void setup() {
  // Attach servos to their respective pins
  servo1.attach(servoPin1);
  servo2.attach(servoPin2);
  servo3.attach(servoPin3);
  servo4.attach(servoPin4);
  servo5.attach(servoPin5);
  servo6.attach(servoPin6);
  
  // Set LDR pin as input
  pinMode(ldrDigitalPin, INPUT);
}

void loop() {
  // Read the digital value from the LDR sensor
  int ldrStatus = digitalRead(ldrDigitalPin);
  
  if (ldrStatus == HIGH) { // Light detected
    // Move all servos to 90 degrees
    servo1.write(90);
    servo2.write(90);
    servo3.write(90);
    servo4.write(90);
    servo5.write(90);
    servo6.write(90);
  } else { // No light detected
    // Move all servos back to 0 degrees
    servo1.write(0);
    servo2.write(0);
    servo3.write(0);
    servo4.write(0);
    servo5.write(0);
    servo6.write(0);
  }
  
  // Small delay to avoid bouncing
  delay(100);
}

This code initializes six servo motors and an LDR sensor. In the setup function, the servos are attached to their respective pins, and the LDR pin is set as an input. In the loop function, the code reads the digital value from the LDR sensor. If light is detected, all servos move to 90 degrees. If no light is detected, the servos return to 0 degrees. A small delay is added to avoid bouncing.