How to build an automatic street light controller using Arduino and an LDR sensor.

Meta Description: Learn how to build an automatic street light controller using Arduino and an LDR sensor. Explore circuit connections, components, Arduino code and how the system works.

1. Introduction

Street lighting is essential for improving visibility, safety and security at night. However, manually switching street lights ON and OFF can be inconvenient and may lead to unnecessary electricity consumption when lights remain ON during daylight.

An Automatic Street Light Controller Using Arduino and LDR Sensor is an electronic project designed to solve this problem.

The system uses a Light Dependent Resistor (LDR) to detect changes in environmental light intensity. During the day, when sufficient sunlight is available, the street light remains OFF. When darkness falls, the LDR detects reduced light intensity and sends a signal to the Arduino, which automatically switches the street light ON.

The project demonstrates how sensors, microcontrollers and electronic switching devices can be combined to develop energy-efficient lighting systems.

Automated Car Parking System using PLC Ladder Logic | Fouzan Mulla posted on the topic | LinkedIn

2. Objectives of the Project

The main objectives are:

  • To design an automatic street lighting system using Arduino.
  • To detect changes in surrounding light intensity using an LDR sensor.
  • To automatically switch street lights ON at night.
  • To switch street lights OFF during daylight.
  • To reduce unnecessary electricity consumption.
  • To demonstrate the application of sensors in automation.
  • To develop a low-cost smart lighting solution.

3. Components and Materials Required

The following components are required to construct the project.

No.ComponentQuantityPurpose
1Arduino Uno1Main microcontroller
2LDR sensor1Detects light intensity
310 kΩ resistor1LDR voltage divider
4LED1Demonstrates street lighting
5220 Ω resistor1Limits LED current
6Breadboard1Circuit assembly
7Jumper wiresAs neededElectrical connections
8USB cable1Programming and power
95V relay module1Optional lamp switching
10DC lamp1Demonstration street light

4. Understanding the LDR Sensor

An LDR (Light Dependent Resistor) is an electronic component whose electrical resistance changes according to the intensity of light falling on its surface.

Its resistance behaves as follows:

  • Bright light: The resistance decreases.
  • Low light: The resistance increases.
  • Darkness: The resistance becomes very high.

The Arduino reads the voltage produced by the LDR voltage divider through its analogue input pin.

This enables the microcontroller to determine whether the surrounding environment is bright or dark.

Photoresistor / Light Dependent Resistor (LDR) Circuit Explained

5. How the Automatic Street Light Controller Works

The project operates through a simple light-detection and switching process.

  • The LDR continuously detects surrounding light intensity.
  • The LDR and 10 kΩ resistor form a voltage divider.
  • The Arduino reads the analogue voltage through pin A0.
  • The Arduino compares the sensor reading with a programmed threshold.
  • When the environment becomes dark, the Arduino switches the LED ON.
  • When daylight returns, the Arduino switches the LED OFF.
Uses Of Ldr In Street Lights at Blake Sadlier blog

6. Circuit Diagram and Arduino Connections

The circuit consists of an Arduino Uno, an LDR sensor, a 10 kΩ resistor and an LED.

For the demonstration, the LED represents the street light. A relay module can later be added to control a higher-power lamp.

สอนใช้งาน Arduino สัญญาณ Analog InPut ตัวต้านทานปรับค่าได้ตามแสง LDR ควบคุมเปิดปิดหลอดไฟ LED - ขาย Arduino อุปกรณ์ Arduino คุณภาพดี ราคาถูก ส่งไว ส่งฟรี

Pin connection table

ComponentArduino connection
LDR terminal 15V
LDR terminal 2A0
10 kΩ resistor terminal 1A0
10 kΩ resistor terminal 2GND
LED anode (+)Digital pin 9 through 220 Ω
LED cathode (-)GND

Understanding the voltage divider

The LDR and 10 kΩ resistor are connected to form a voltage divider.

  • One LDR terminal is connected to 5V.
  • The other LDR terminal is connected to A0.
  • A 10 kΩ resistor connects A0 to GND.

When light intensity decreases, the LDR resistance increases, causing the analogue reading at A0 to decrease.

This arrangement allows the Arduino to detect darkness using a programmed threshold.

7. Step-by-Step Project Construction

Follow these steps to assemble the automatic street light controller.

Step 1: Prepare the Arduino Uno

Place the Arduino Uno on a flat working surface and connect it to a computer using a USB cable.

Step 2: Connect the LDR sensor

Connect one terminal of the LDR to the 5V supply and the other terminal to analogue pin A0.

Step 3: Connect the 10 kΩ resistor

Connect the 10 kΩ resistor between A0 and GND to complete the voltage divider.

Step 4: Connect the LED

Connect the LED anode to digital pin 9 through a 220 Ω resistor. Connect its cathode to GND.

Step 5: Upload the Arduino program

Write the Arduino code, select Arduino Uno in the IDE and upload the program.

Step 6: Test the system

Expose the LDR to bright light and observe the LED. Cover the LDR to simulate darkness and check whether the LED switches ON.

How To Measure Light Intensity Using Ldr at Rhonda Freese blog

8. Arduino IDE Programming Code

The following Arduino program automatically switches the LED ON when the surrounding environment becomes dark and OFF when sufficient light is detected.


// Automatic Street Light Controller
// Using Arduino Uno and LDR Sensor

const int ldrPin = A0;
const int ledPin = 9;

// Adjust after testing your LDR
const int threshold = 500;

int lightValue = 0;

void setup() {

  pinMode(ledPin, OUTPUT);

  Serial.begin(9600);

}

void loop() {

  // Read light intensity
  lightValue = analogRead(ldrPin);

  Serial.print("LDR Reading: ");
  Serial.println(lightValue);

  // Switch ON when it is dark
  if (lightValue < threshold) {

    digitalWrite(ledPin, HIGH);

    Serial.println("Darkness Detected: Light ON");

  }

  // Switch OFF during daylight
  else {

    digitalWrite(ledPin, LOW);

    Serial.println("Daylight Detected: Light OFF");

  }

  delay(500);

}

Explanation of the Arduino code

Code instructionFunction
const int ldrPin = A0;Defines the LDR input pin
const int ledPin = 9;Defines the LED output pin
analogRead(ldrPin)Reads the LDR voltage
threshold = 500Sets the switching reference value
digitalWrite(ledPin, HIGH)Switches the LED ON
digitalWrite(ledPin, LOW)Switches the LED OFF
delay(500)Pauses for half a second

Important: The threshold value of 500 is an example. Actual readings depend on the LDR, resistor and surrounding light conditions. Use the Serial Monitor to determine a suitable threshold.

9. Testing and Expected Results

After uploading the code, test the project under different lighting conditions.

Test conditionLDR readingExpected result
Bright sunlightAbove thresholdLight OFF
Normal daylightAbove thresholdLight OFF
Dim environmentBelow thresholdLight ON
Complete darknessBelow thresholdLight ON
Lamp Post

Daytime

Light OFF

Фонарь желтый свет (54 фото) - красивые картинки и HD фото

Nighttime

Light ON

10. Improving the Project Using a Relay Module

The basic project uses an LED to demonstrate automatic switching. However, a practical street lighting system may require a relay module to control a suitable external lamp.

The relay module acts as an electrically controlled switch.

Additional components

  • 5V relay module.
  • Suitable street lighting load.
  • Appropriate power supply.
  • Insulated electrical enclosure.

Relay connections

Relay moduleArduino
VCC5V
GNDGND
INDigital pin 8

The Arduino sends a control signal to the relay when darkness is detected.

The relay then switches the connected lamp ON. During daylight, the relay switches the lamp OFF.

Electrical safety: Do not connect a mains-powered street lamp directly to Arduino pins or an exposed breadboard. Mains voltage can cause fatal electric shock. Any AC wiring must use an appropriately rated relay, enclosure, fuse and isolation, and should be installed by a qualified electrician.

11. Applications of the Automatic Street Light Controller

This project can be applied in different environments where automatic lighting is required.

  • Roads and highways: Automatically controls street lighting based on daylight conditions.
  • Schools: Controls security lights around school compounds.
  • Residential estates: Automates outdoor lighting.
  • Parking areas: Provides automatic lighting at night.
  • Industrial facilities: Controls outdoor security lighting.
  • Smart cities: Supports intelligent street lighting infrastructure.
  • Farm environments: Automates lighting around farm buildings and pathways.

12. Advantages of the Project

  • Saves electricity by switching lights OFF during daylight.
  • Reduces the need for manual operation.
  • Uses affordable and readily available components.
  • Provides automatic day-and-night operation.
  • Demonstrates practical applications of Arduino programming.
  • Can be expanded to control multiple street lights.
  • Promotes energy efficiency and smart infrastructure.

13. Possible Project Improvements

The basic system can be upgraded to make it more intelligent and efficient.

Smart Street Light Using NodeMCU and IOT ThingSpeak : 6 Steps - Instructables
Create arduino electronics project with circuit and code by Ameerhuzaifa | Fiverr
Intensity Controlled Automatic Street Light with Solar and Rechargeable Battery – SR Robotics
Street Light that Glows on Detecting Vehicle Movement – LiveMyTraining
(PDF) Internet-of-Things for Smart Street Lighting System using ESP8266 on Mesh Network
Circuit design Smart Street Light - Tinkercad
Intelligent Street Light Using LoRa : 5 Steps - Instructables
Solar Smart Lighting Platform Solar Smart Lighting System (SSLS)
Circuit design Smart Street Light System - Tinkercad
Nghiên cứu thiết kế hệ thống đèn LED sử dụng pin mặt trời chiếu sáng đường phố và công viên
Building a Smart IoT Street Lighting System with Fault Detection - DEV Community
Circuit design Smart street light system - Tinkercad
Intensity Controlled Street Light System with Solar Power using Arduino Uno – SR Robotics
A Survey on IOT based Real Time, Smart Adaptive Street Lighting System with Pollution Monitoring for Smart Cities							| International Journal on Recent and Innovation Trends in Computing and Communication
automatic street light control using aurdino,PIR,LDR tinker cad circuit | PPTX

A. Integration of PIR Motion Sensor

A PIR sensor can detect moving pedestrians and vehicles. The system can increase lighting when movement is detected and reduce brightness when the road is empty.

B. Solar Power Integration

A solar panel and rechargeable battery can be added to power the street lighting system independently.

C. IoT Monitoring

An ESP32 or ESP8266 can be integrated to allow remote monitoring and control through a web dashboard.

D. Multiple Street Light Control

Several street lights can be connected through suitable switching circuits to create an automated lighting network.

E. Adjustable Light Intensity

PWM control can be used with compatible LED drivers to adjust brightness depending on environmental conditions.

14. Troubleshooting Common Arduino Upload Errors

ProblemPossible causeSolution
Arduino not detectedUSB connection problemCheck USB cable and port
LED does not switch ONIncorrect wiringCheck LED polarity and connections
LDR readings remain constantIncorrect voltage dividerCheck LDR and resistor connections
LED remains ONIncorrect thresholdCheck Serial Monitor readings
LED switches randomlyChanging light intensityAdjust threshold and introduce hysteresis
Compilation errorIncorrect codeCheck syntax and board selection

15. Conclusion

The Automatic Street Light Controller Using Arduino and LDR Sensor demonstrates how simple electronic components can be used to develop an intelligent lighting system.

By combining an LDR sensor with an Arduino Uno, the project automatically detects changes in environmental light intensity and controls street lighting without requiring manual operation.

The project offers an affordable introduction to automation, sensor technology, microcontroller programming and energy conservation.

With additional components such as PIR sensors, solar panels, relay modules and IoT connectivity, the system can be upgraded into a more advanced smart street lighting solution.

It is an excellent STEM project for students interested in electronics, renewable energy, programming and smart infrastructure.

mbeva

Dominic Mbeva is a science teacher, experienced researcher, innovator, and creative technologist with expertise in STEM education, digital media, and scientific research. As a Kenya Science and Engineering Fair (KSEF) advisor and projects manager, he mentors young scientists, guiding them in developing award-winning innovations. He is also an IC Technorat, leading advancements in science and technology. Beyond education, Dominic is a skilled photographer and video editor, using visual storytelling to make science more engaging. His philosophy, “If you take care of minutes, hours will take care of themselves,” reflects his belief in consistent effort, strategic thinking, and innovation to drive success in both research and creativity.

Related Posts

How to Make a Smart River Water Level and Pollution Monitoring Boat / Buoy Using ESP32 and GPS

Meta Description: Learn how to build a smart river water level and pollution monitoring boat using ESP32, GPS and water quality sensors. Includes components, circuit connections, Arduino code and IoT…

Read more

How to Make an Ultrasonic Reverse Parking Sensor System Using Arduino, Buzzer, and LCD

Meta Description: Learn how to build an ultrasonic reverse parking sensor using Arduino, HC-SR04 sensor, buzzer and LCD. Follow the circuit connections, programming code and step-by-step construction guide. 1. Introduction…

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *