|

Arduino Smart Street Light Project Using LDR Sensor: Circuit & Code

Arduino Smart Automatic Street Light Project Using LDR Sensor

Have you ever wondered how street lights can automatically turn on when it gets dark and turn off when sunlight returns?

You can build a simple version of this system using an Arduino Uno, LDR sensor, LED, and a few basic electronic components.

In this Arduino Smart Street Light Project, the LDR sensor detects the surrounding light level. The Arduino reads the sensor value and automatically controls an LED.

During the daytime, when there is enough light, the LED remains OFF. When the surrounding environment becomes dark, the LED automatically turns ON.

This is a simple Arduino project, but it introduces several important concepts such as sensors, analog input, digital output, conditional statements, and automation.


What Is an Arduino Smart Street Light?

An Arduino smart street light is an automatic lighting system that can control a light based on the amount of surrounding light.

Instead of manually switching the light on and off, a sensor detects whether it is day or night.

The basic working principle is:

☀️ Bright Environment
        ↓
    LDR detects light
        ↓
      Arduino
        ↓
     LED OFF

And when it becomes dark:

🌙 Dark Environment
        ↓
    LDR detects darkness
        ↓
      Arduino
        ↓
      LED ON

This basic concept can be expanded into a larger smart lighting system using multiple LEDs, motion sensors, IoT technology, and other components.


Components Required

You only need a few components for this project.

ComponentQuantity
Arduino Uno1
LDR Sensor1
LED1
10KΩ Resistor1
220Ω Resistor1
Breadboard1
Jumper WiresSeveral
USB Cable1

Optional Components

For a more advanced version, you can also use:

  • PIR motion sensor
  • Multiple LEDs
  • LCD/OLED display
  • Buzzer
  • Relay module
  • External power supply

Arduino Smart Street Light Project using LDR Sensor

What Is an LDR Sensor?

LDR stands for Light Dependent Resistor.

It is a type of resistor whose resistance changes depending on the amount of light falling on its surface.

In simple terms:

More light → LDR resistance changes

Less light → LDR resistance changes

This property allows the Arduino to determine whether the environment is bright or dark.

An LDR is also commonly called a photoresistor.


How Does the LDR Work?

The LDR is connected with a resistor to create a voltage divider circuit.

The Arduino reads the voltage from the divider through one of its analog input pins.

For example:

        5V
         |
        LDR
         |
         +-------- A0
         |
       10KΩ
         |
        GND

The voltage at the middle point changes depending on the amount of light detected by the LDR.

The Arduino can then read this value using:

analogRead(A0);

The Arduino Uno’s analog input can provide a value in the approximate range:

0 → 1023

The exact value depends on the circuit configuration and lighting conditions.


Arduino Smart Street Light Circuit

For this example, connect the components as follows.

LDR Connections

LDR CircuitArduino
Voltage divider outputA0
Supply5V
GroundGND

LED Connections

LEDArduino
Anode through 220Ω resistorD9
CathodeGND

So the basic structure becomes:

LDR
 ↓
A0
 ↓
Arduino Uno
 ↓
D9
 ↓
220Ω Resistor
 ↓
LED
 ↓
GND

Important: LED Polarity

Before connecting the LED, identify its two legs.

Usually:

  • Longer leg → Anode (+)
  • Shorter leg → Cathode (-)

The LED should be connected with the correct polarity.

Also, use a current-limiting resistor such as 220Ω in series with the LED.


Arduino Smart Street Light Code

Here is a simple Arduino program for the project:

int ldrPin = A0;
int ledPin = 9;

int lightValue = 0;

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

  Serial.begin(9600);
}

void loop() {

  lightValue = analogRead(ldrPin);

  Serial.println(lightValue);

  if (lightValue < 500) {
    digitalWrite(ledPin, HIGH);
  }
  else {
    digitalWrite(ledPin, LOW);
  }

  delay(200);
}

Understanding the Arduino Code

Let’s understand the program step by step.

1. Define the LDR Pin

int ldrPin = A0;

Here, we tell the Arduino that the LDR sensor’s analog output is connected to A0.


2. Define the LED Pin

int ledPin = 9;

The LED is connected to digital pin 9.


3. Create a Variable for the Sensor Reading

int lightValue = 0;

This variable stores the value obtained from the LDR.


4. Configure the LED

Inside setup():

pinMode(ledPin, OUTPUT);

This tells the Arduino that pin 9 will be used as an output.


5. Read the LDR

Inside the loop() function:

lightValue = analogRead(ldrPin);

The Arduino reads the analog value from the LDR.


6. Display the Sensor Value

Serial.println(lightValue);

This sends the sensor value to the Arduino IDE’s Serial Monitor.

This is useful when determining the correct threshold for your environment.


How the Automatic Switching Works

The important part of the program is:

if (lightValue < 500) {
  digitalWrite(ledPin, HIGH);
}
else {
  digitalWrite(ledPin, LOW);
}

The Arduino compares the sensor value with 500.

If the value is below 500:

Dark → LED ON

If the value is 500 or higher:

Bright → LED OFF

However, the correct threshold can vary depending on your LDR circuit and lighting conditions.


Useful Arduino Resources

How to Find the Correct LDR Threshold

You don’t necessarily have to use 500.

Different environments produce different sensor values.

For example, you might observe:

Bright room → 800
Normal room → 600
Dim room → 400
Dark → 150

In that case, a threshold around 500 may work well.

The best way to determine the value is to open:

Arduino IDE → Serial Monitor

and observe the values while covering and uncovering the LDR.

Then change:

if (lightValue < 500)

to a value suitable for your circuit.


Step-by-Step: Build the Project

Step 1: Prepare the Components

Collect all the required components:

  • Arduino Uno
  • LDR
  • 10KΩ resistor
  • LED
  • 220Ω resistor
  • Breadboard
  • Jumper wires

Step 2: Build the LDR Circuit

Create the voltage divider using the LDR and 10KΩ resistor.

Connect its output to:

Arduino A0

Step 3: Connect the LED

Connect the LED through a 220Ω resistor to:

Arduino D9

Connect the other side of the LED to GND.


Step 4: Connect Arduino to Your Computer

Use a USB cable to connect the Arduino Uno to your computer.


Step 5: Open Arduino IDE

Open Arduino IDE and create a new sketch.

Paste the code into the editor.


Step 6: Select Arduino Board

Select:

Board → Arduino Uno

Then choose the correct COM port.


Step 7: Upload the Program

Click:

Verify

and then:

Upload

After the upload finishes, the Arduino will start reading the LDR sensor.


Testing the Project

Now test the project.

Test 1: Bright Light

Expose the LDR to a bright light source.

The Arduino should detect a higher light value and turn the LED:

OFF

Test 2: Cover the LDR

Cover the LDR with your hand or place it in a darker area.

The sensor value should change.

When it crosses the threshold, the LED should turn:

ON

This demonstrates automatic light control.


Simple Working Diagram

The complete working process can be represented as:

       LIGHT
         ↓
      ┌─────┐
      │ LDR │
      └──┬──┘
         ↓
   Analog Signal
         ↓
   ┌───────────┐
   │  Arduino  │
   │    Uno    │
   └─────┬─────┘
         ↓
     Digital Pin
         ↓
       ┌───┐
       │LED│
       └───┘

How to Make the Project More Advanced

The basic project is useful for learning, but you can add several features to make it more advanced.

1. Add Multiple LEDs

Instead of using one LED, you can use several LEDs to represent multiple street lights.

For example:

Arduino
  ├── LED 1
  ├── LED 2
  ├── LED 3
  ├── LED 4
  └── LED 5

When darkness is detected, all the LEDs can turn on.


2. Add a PIR Motion Sensor

A PIR sensor can detect movement.

Then the system can become smarter:

Dark + No Vehicle
       ↓
Low brightness / OFF
       
Dark + Vehicle Detected
       ↓
Bright street light

This can reduce unnecessary energy consumption.


3. Add PWM Brightness Control

Instead of simply switching the LED ON and OFF, Arduino PWM can be used to control brightness.

For example:

Day → OFF
Evening → 30%
Night → 70%
Vehicle detected → 100%

This creates a more advanced smart lighting system.


4. Add an LCD Display

An LCD can display the current light level.

For example:

Light Level:
428

Status:
NIGHT

This makes the project more interactive.


5. Add IoT Features

You can connect the system to Wi-Fi using an ESP8266 or ESP32.

Then you could potentially monitor:

  • Light status
  • Sensor values
  • Energy usage
  • Fault conditions

from a web dashboard or mobile application.


Applications of Arduino Smart Street Light

This project demonstrates the basic principle behind automatic lighting systems.

Possible applications and demonstrations include:

  • Smart city prototypes
  • Automatic garden lighting
  • Home automation
  • School science projects
  • Electronics exhibitions
  • Energy-saving lighting concepts
  • Outdoor lighting prototypes
  • IoT-based lighting systems

Real-world street-light systems are generally much more sophisticated and use dedicated controllers, sensors, power electronics, and infrastructure.


Advantages

The Arduino-based smart street light has several advantages:

⚡ Automatic Operation

The light can turn on and off automatically according to the surrounding light level.

💡 Energy Saving

Automatic control can help avoid leaving lights unnecessarily switched on.

💰 Low Cost Prototype

The basic prototype requires only a few inexpensive components.

🧑‍💻 Easy to Program

The Arduino code can be modified easily.

🔧 Easy to Upgrade

You can add sensors, displays, wireless connectivity, and more LEDs later.


Limitations

There are also some limitations to the basic prototype.

LDR Sensitivity

The sensor can be affected by nearby artificial lights.

Fixed Threshold

A simple if condition uses a fixed threshold, so it may need adjustment.

Prototype Scale

A small LED circuit cannot directly power real street lights.

For high-power lighting, suitable drivers, relays, MOSFETs, power supplies, and electrical safety measures are required.


Troubleshooting

LED Always Stays ON

Check:

  • LDR wiring
  • 10KΩ resistor
  • Analog pin A0
  • Threshold value
  • Sensor readings in Serial Monitor

LED Always Stays OFF

Try covering the LDR and observe the value.

If the value changes but the LED doesn’t, check:

  • LED polarity
  • 220Ω resistor
  • Digital pin 9
  • GND connection

Sensor Values Don’t Change

Check:

  • LDR connections
  • A0 connection
  • 5V connection
  • GND connection
  • Breadboard connections

Also make sure the LDR is exposed to changing light levels.


Frequently Asked Questions

Can I use Arduino Nano instead of Arduino Uno?

Yes. Arduino Nano can perform the same basic function, provided the wiring and pin configuration are adjusted correctly.

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

Yes. Many LDR modules already include a voltage-divider circuit and may provide digital and/or analog outputs. The wiring and code will depend on the specific module.

Can I control a real street light with Arduino?

A small Arduino cannot directly drive a mains-powered street light. High-power lighting requires appropriate switching hardware, power supplies, isolation, and proper electrical safety practices.

Can I change the sensitivity?

Yes. You can change the threshold value in the Arduino code, or use a potentiometer with an appropriate LDR circuit/module for easier adjustment.

Is this project suitable for beginners?

Yes. It is a good beginner project for learning Arduino analog input, sensors, LEDs, and automatic control.


Conclusion

The Arduino Smart Automatic Street Light Project is an excellent beginner-friendly project for understanding how sensors can be used to automate everyday tasks.

By combining an Arduino Uno, LDR sensor, resistor, and LED, you can create a simple system that detects the surrounding light level and automatically controls the light.

The project can also be expanded with multiple LEDs, PIR sensors, PWM brightness control, LCD displays, ESP32/ESP8266 connectivity, and IoT features.

If you’re learning Arduino, this project is a great step after basic LED projects because it introduces an important concept: using real-world sensor data to make an automated decision.

Similar Posts

Leave a Reply

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