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

Solar-Powered Arduino Security Light with Motion Detection

View and Edit Project In Cirkit DesignerImage of Solar-Powered Arduino Security Light with Motion Detection

Solar-Powered Motion-Activated LED Circuit Documentation

Summary

This circuit is designed to harness solar energy to charge a 9V battery, which in turn powers an Arduino UNO microcontroller along with a Light-Dependent Resistor (LDR), a Passive Infrared (PIR) motion sensor, and an LED. The Arduino UNO reads the ambient light level through the LDR and detects motion via the PIR sensor. When the environment is dark and motion is detected, the LED is turned on, indicating the presence of an individual or moving object.

Component List

Solar Panel

Solar Charge Controller

Battery 9V

LDR (Light-Dependent Resistor)

PIR/Motion Sensor

LED: Two Pin (red)

Arduino UNO

Wiring Details

Solar Panel

Solar Charge Controller

Battery 9V

LDR

PIR/Motion Sensor

LED: Two Pin (red)

Arduino UNO

Documented Code

// sketch.ino
const int ldrPin = A0; // LDR connected to A0
const int pirPin = 2;  // PIR sensor connected to D2
const int ledPin = 13; // LED connected to D13

void setup() {
  pinMode(ldrPin, INPUT); // Set LDR pin as input
  pinMode(pirPin, INPUT); // Set PIR pin as input
  pinMode(ledPin, OUTPUT); // Set LED pin as output
  Serial.begin(9600); // Initialize serial communication
}

void loop() {
  int ldrValue = analogRead(ldrPin); // Read LDR value
  int pirValue = digitalRead(pirPin); // Read PIR value

  Serial.print("LDR Value: ");
  Serial.println(ldrValue);
  Serial.print("PIR Value: ");
  Serial.println(pirValue);

  // Check if it is dark and motion is detected
  if (ldrValue < 500 && pirValue == HIGH) {
    digitalWrite(ledPin, HIGH); // Turn on LED
  } else {
    digitalWrite(ledPin, LOW); // Turn off LED
  }

  delay(1000); // Wait for 1 second
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It initializes the LDR and PIR sensor as inputs and the LED as an output. The loop function continuously reads the values from the LDR and PIR sensor, printing them to the serial monitor. If the LDR value indicates low light (value below 500) and the PIR sensor detects motion (value is HIGH), the LED is turned on. Otherwise, the LED is turned off. The system pauses for 1 second between each loop iteration.