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.
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. | Component | Quantity | Purpose |
|---|---|---|---|
| 1 | Arduino Uno | 1 | Main microcontroller |
| 2 | LDR sensor | 1 | Detects light intensity |
| 3 | 10 kΩ resistor | 1 | LDR voltage divider |
| 4 | LED | 1 | Demonstrates street lighting |
| 5 | 220 Ω resistor | 1 | Limits LED current |
| 6 | Breadboard | 1 | Circuit assembly |
| 7 | Jumper wires | As needed | Electrical connections |
| 8 | USB cable | 1 | Programming and power |
| 9 | 5V relay module | 1 | Optional lamp switching |
| 10 | DC lamp | 1 | Demonstration 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.
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.
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.
Pin connection table
| Component | Arduino connection |
|---|---|
| LDR terminal 1 | 5V |
| LDR terminal 2 | A0 |
| 10 kΩ resistor terminal 1 | A0 |
| 10 kΩ resistor terminal 2 | GND |
| 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.
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 instruction | Function |
|---|---|
| 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 = 500 | Sets 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 condition | LDR reading | Expected result |
|---|---|---|
| Bright sunlight | Above threshold | Light OFF |
| Normal daylight | Above threshold | Light OFF |
| Dim environment | Below threshold | Light ON |
| Complete darkness | Below threshold | Light ON |
Daytime
Light OFF
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 module | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| IN | Digital 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.
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
| Problem | Possible cause | Solution |
|---|---|---|
| Arduino not detected | USB connection problem | Check USB cable and port |
| LED does not switch ON | Incorrect wiring | Check LED polarity and connections |
| LDR readings remain constant | Incorrect voltage divider | Check LDR and resistor connections |
| LED remains ON | Incorrect threshold | Check Serial Monitor readings |
| LED switches randomly | Changing light intensity | Adjust threshold and introduce hysteresis |
| Compilation error | Incorrect code | Check 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.







