Automatic Street Light Using an LDR Sensor

December 1, 2026 · fareedahmed486

Automatic Street Light Using an LDR Sensor

Automatic Street Light Using an LDR Sensor

Learn how to build an automatic street light system using an LDR (Light Dependent Resistor) and Arduino. This beginner-friendly electronics project switches the light ON automatically when the surroundings become dark and turns it OFF when daylight returns.

The project is useful for learning about light sensors, Arduino analog inputs, automatic lighting, and energy-saving systems.

Introduction

Street lights are an important part of road safety, but manually switching them ON and OFF can waste electricity and require regular attention. An automatic street light system solves this problem by detecting the surrounding light and controlling the lamp automatically.

In this project, we will build an automatic street light using an LDR sensor and Arduino UNO. The LDR detects the intensity of surrounding light. During daylight, the street light remains OFF. When the environment becomes dark, the Arduino detects the change and switches the light ON.

This is a useful Arduino project for beginners, students, robotics enthusiasts, and anyone interested in electronics and energy-saving automation.

1. What Is an LDR Sensor?

An LDR (Light Dependent Resistor), also called a photoresistor, is an electronic component whose resistance changes according to the amount of light falling on its surface.

Its resistance behaves as follows:

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

Arduino cannot measure resistance directly, so the LDR is connected with a fixed resistor to create a voltage divider. Arduino reads the changing voltage through an analog input pin.

2. Components Required

You will need the following electronic components to build this automatic street light project:

Component Quantity Purpose
Arduino UNO 1 Main controller
LDR sensor 1 Detects surrounding light
10kΩ resistor 1 Creates voltage divider
LED 1 Represents the street light
220Ω resistor 1 Limits LED current
Breadboard 1 Circuit assembly
Jumper wires As required Electrical connections
USB cable 1 Arduino programming and power

For a larger low-voltage LED lamp, use a suitably rated transistor or MOSFET driver instead of powering the lamp directly from an Arduino pin.

3. How Does an Automatic Street Light Work?

The system works by continuously checking the light intensity using the LDR sensor.

During the daytime:

  1. Sunlight falls on the LDR.
  2. The LDR resistance decreases.
  3. The Arduino receives a higher analog reading in the circuit used here.
  4. The Arduino keeps the LED OFF.

During nighttime:

  1. The surrounding light becomes weaker.
  2. The LDR resistance increases.
  3. The Arduino receives a lower analog reading.
  4. The Arduino switches the LED ON.

This process repeats automatically without requiring a manual switch.

4. Circuit Diagram and Wiring Connections

For this beginner version, we will use an Arduino UNO, one LDR, a 10kΩ resistor, and an LED.

LDR Sensor Connections

Connect the LDR and 10kΩ resistor as a voltage divider:

Component Connection
First LDR leg Arduino 5V
Second LDR leg Arduino A0
10kΩ resistor first leg Arduino A0
10kΩ resistor second leg Arduino GND

The LDR has no positive or negative polarity, so its two legs can be connected either way around.

LED Connections

LED Component Connection
LED long leg (Anode +) Arduino digital pin 9 through 220Ω resistor
LED short leg (Cathode −) Arduino GND

Complete Pinout

Arduino UNO Pin Component
5V LDR first leg
A0 LDR second leg and 10kΩ resistor
GND Other end of 10kΩ resistor
D9 LED anode through 220Ω resistor
GND LED cathode

Important: The 10kΩ resistor is required to create the voltage divider. Without it, the analog input may produce unstable readings.

5. Arduino Code for Automatic Street Light

Upload the following code to your Arduino UNO using the Arduino IDE.

// Automatic Street Light Using LDR Sensor
// Arduino UNO

const int LDR_PIN = A0;
const int LIGHT_PIN = 9;

// Adjust these values after testing your LDR
const int DARK_ON = 400;
const int BRIGHT_OFF = 500;

bool lightState = false;

void setup() {
  pinMode(LIGHT_PIN, OUTPUT);

  digitalWrite(LIGHT_PIN, LOW);

  Serial.begin(9600);
}

void loop() {
  int ldrValue = analogRead(LDR_PIN);

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

  // Turn street light ON in darkness
  if (ldrValue < DARK_ON) {
    lightState = true;
  }

  // Turn street light OFF in bright conditions
  else if (ldrValue > BRIGHT_OFF) {
    lightState = false;
  }

  digitalWrite(LIGHT_PIN, lightState ? HIGH : LOW);

  delay(200);
}

Code Explanation

  • LDR_PIN = A0: Reads the analog signal from the LDR voltage divider.
  • LIGHT_PIN = 9: Controls the LED.
  • analogRead(): Reads the light level as a value between 0 and 1023 on an Arduino UNO.
  • DARK_ON: Sets the reading below which the light turns ON.
  • BRIGHT_OFF: Sets the reading above which the light turns OFF.
  • digitalWrite(): Controls the LED according to the detected light level.

The two different thresholds prevent the street light from repeatedly switching ON and OFF when the light level is close to the switching point. This technique is called hysteresis.

Note: The example thresholds are starting values, not universal settings. Your LDR readings will depend on the sensor, resistor, and surrounding light.

6. How to Adjust the LDR Sensor Sensitivity

You may need to adjust the code for your environment.

Follow these steps:

  1. Connect the Arduino UNO to your computer.
  2. Upload the code.
  3. Open the Arduino IDE Serial Monitor.
  4. Set the baud rate to 9600.
  5. Observe the LDR readings in normal light.
  6. Cover the LDR with your hand and observe the readings again.
  7. Set DARK_ON and BRIGHT_OFF according to your measured values.

For example, if your bright-light readings are around 800 and dark readings are around 250, you could try:

const int DARK_ON = 350;
const int BRIGHT_OFF = 500;

Test the values in your actual environment to get reliable switching.

7. Testing the Automatic Street Light

After completing the wiring and uploading the code, test the circuit:

Test 1: Daylight

Expose the LDR to bright light. The LED should remain OFF.

Test 2: Darkness

Cover the LDR with your hand or place it in a dark environment. The LED should turn ON.

Test 3: Changing Light

Move the LDR between bright and dark conditions. The LED should automatically respond to the changing light level.

If the LED behaves in the opposite way, check your voltage-divider wiring and confirm the sensor readings in the Serial Monitor.

8. Applications of Automatic Street Light Systems

Automatic lighting systems can be used in many places, including:

  • Street lighting: Automatically controls road and roadside lights.
  • Garden lighting: Switches outdoor lights ON after sunset.
  • Parking areas: Controls lights according to surrounding brightness.
  • Home automation: Operates outdoor and entrance lights automatically.
  • School projects: Demonstrates sensors, automation, and Arduino programming.
  • Energy-saving systems: Helps avoid unnecessary daytime lighting.

9. Advantages of Using an LDR Sensor

An LDR-based automatic street light system offers several advantages:

  1. Automatic operation: No manual switching is required.
  2. Low cost: An LDR and a few basic components are inexpensive.
  3. Easy to build: Suitable for beginners learning Arduino.
  4. Energy saving: Prevents lights from remaining ON during daylight.
  5. Expandable design: Can be upgraded with relays, MOSFETs, timers, or IoT controllers.

10. Possible Project Upgrades

Once the basic circuit is working, you can improve it with additional components:

  • Relay module: Control a properly rated external lighting circuit.
  • MOSFET driver: Switch a low-voltage DC LED strip or lamp.
  • Multiple LDR sensors: Monitor different areas.
  • ESP32 or Wi-Fi: Add remote monitoring and smart control.
  • Solar panel and battery: Explore an off-grid street lighting prototype.
  • Display module: Show the current light reading on an LCD or OLED screen.

For more advanced projects, explore Arduino boards and accessories at Electroway. You can also explore the Electroway app as part of your electronics shopping experience.

11. Common Problems and Troubleshooting

Problem Possible Solution
LED does not turn ON Check LED polarity, D9 connection, and GND
LED always stays ON Check LDR wiring and threshold values
LED always stays OFF Cover the LDR and inspect Serial Monitor readings
Readings fluctuate Check jumper wires and resistor connections
Light switches too frequently Increase the gap between the two thresholds
Arduino does not upload code Check USB cable and selected board/port

12. Electrical Safety Precautions

This tutorial uses a low-voltage LED prototype. Keep the beginner circuit powered through the Arduino USB connection or a suitable regulated low-voltage supply.

  • Never connect a 220–240V AC street lamp directly to an Arduino pin or breadboard.
  • Do not handle exposed mains wiring.
  • A relay module or driver must have suitable voltage, current, and isolation ratings for its intended application.
  • Real outdoor street lighting requires weatherproof enclosures, proper insulation, circuit protection, and installation by a qualified electrician.

A small LED prototype demonstrates the control principle; it is not a complete, installation-ready street lighting system.

Frequently Asked Questions (FAQs)

1. What is an LDR sensor used for in an automatic street light?

An LDR detects the surrounding light intensity. It helps the controller switch the street light OFF during daylight and ON when it becomes dark.

2. Can I make an automatic street light using Arduino UNO?

Yes. Arduino UNO can read the LDR voltage through an analog input and control an LED or a suitable external driver.

3. Why do we use a 10kΩ resistor with an LDR?

The 10kΩ resistor forms a voltage divider with the LDR. This produces a measurable voltage that the Arduino can read through its analog input.

4. Can I use an LDR module instead of a bare LDR?

Yes, but check the module pins and output type. An analog output (AO) can provide a changing light reading, while a digital output (DO) generally provides a HIGH or LOW signal based on its adjustable threshold.

5. Can this project control a real street light?

The Arduino can control a suitable driver or relay, but a real street light requires correctly rated electrical equipment, proper isolation, protection, and professional installation. Do not connect mains voltage directly to the Arduino.

6. Can I use this project without Arduino?

Yes. An LDR can also be used with a transistor or comparator-based circuit to switch a low-voltage light automatically. Arduino makes it easier to adjust thresholds and add more features.