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

Arduino UNO-Based Smart Street Light Control with PIR and LDR Sensors

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Street Light Control with PIR and LDR Sensors

Circuit Documentation

Summary

This project is a Street Light Control System that uses an Arduino UNO microcontroller to control street lights based on inputs from a Light Dependent Resistor (LDR) sensor and two Passive Infrared (PIR) sensors. The LDR sensor determines whether it is day or night, and the PIR sensors detect motion. At night, three LEDs are turned on via a transistor switch, and an additional LED is turned on when motion is detected.

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. PIR Sensor

    • Description: Passive Infrared sensor for motion detection.
    • Pins: VDD, SIG, GND
  3. LED: Two Pin (red)

    • Description: Red LED.
    • Pins: Cathode, Anode
  4. LED: Two Pin (blue)

    • Description: Blue LED.
    • Pins: Cathode, Anode
  5. Resistor

    • Description: Resistor with a resistance of 200 Ohms.
    • Pins: Pin1, Pin2
  6. 12v Battery

    • Description: Power source.
    • Pins: -, +
  7. NPN-Transistor

    • Description: NPN Bipolar Junction Transistor.
    • Pins: E, C, B
  8. Photoresistor (LDR) Sensor (Wokwi Compatible)

    • Description: Light Dependent Resistor sensor.
    • Pins: VCC, GND, DO, AO

Wiring Details

Arduino UNO

PIR Sensor

LED: Two Pin (red)

LED: Two Pin (blue)

Resistor

12v Battery

NPN-Transistor

Photoresistor (LDR) Sensor (Wokwi Compatible)

Code Documentation

/*
 * Street Light Control Project
 * This code controls street lights based on LDR and PIR sensors.
 * - LDR sensor determines day/night.
 * - At night, three LEDs are turned on via a transistor switch.
 * - PIR sensor detects motion to turn on an additional LED.
 */

const int ldrPin = A5; // LDR sensor pin
const int pirPin1 = 2; // PIR sensor 1 pin
const int pirPin2 = 4; // PIR sensor 2 pin
const int ledPin1 = 8; // LED controlled by transistor
const int ledPin2 = 9; // LED controlled by transistor
const int ledPin3 = 10; // LED controlled by transistor
const int motionLedPin = 3; // LED for motion detection

void setup() {
  pinMode(ldrPin, INPUT);
  pinMode(pirPin1, INPUT);
  pinMode(pirPin2, INPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(motionLedPin, OUTPUT);
  digitalWrite(ledPin1, LOW);
  digitalWrite(ledPin2, LOW);
  digitalWrite(ledPin3, LOW);
  digitalWrite(motionLedPin, LOW);
}

void loop() {
  int ldrValue = analogRead(ldrPin);
  int pirValue1 = digitalRead(pirPin1);
  int pirValue2 = digitalRead(pirPin2);

  // Check if it is night time
  if (ldrValue < 500) { // Adjust threshold as needed
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
  } else {
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
  }

  // Check for motion detection
  if (pirValue1 == HIGH || pirValue2 == HIGH) {
    digitalWrite(motionLedPin, HIGH);
  } else {
    digitalWrite(motionLedPin, LOW);
  }

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

This code initializes the pins for the LDR sensor, PIR sensors, and LEDs. In the loop function, it reads the values from the LDR and PIR sensors. If the LDR sensor detects that it is night (value below 500), it turns on three LEDs. If either of the PIR sensors detects motion, it turns on an additional LED.