Robotics • FREE PROJECT

Automatic Street Light

Automatic Street Light circuit diagram
Intermediate Robotics ⏱ 90 Minutes

Build a smart street light that automatically turns ON when it gets dark and OFF during daylight using an LDR sensor. This concept is commonly used in street lights, garden lights, parking areas, and energy-saving lighting systems.

What You Will Learn

  • How IR (infrared) line sensors detect surfaces
  • Driving a motor driver module (L298N)
  • Basic if/else steering logic
  • Tuning sensor thresholds for real-world lighting

Components Required

Arduino UNO R3 LDR 10kΩ Resistor 5mm LED 220Ω Resistor Breadboard Jumper Wires
BUILD IT STEP BY STEP

Follow along and build with confidence.

Every step includes a visual reference and a plain-language explanation, so you always know what to do next.

STEP 01

Upload the Code

💻

This logic reads both IR sensors: if the left sensor sees the line, it steers left; if the right sensor sees it, it steers right; if both see black, it drives straight.

cpp
const int ldrPin = A0;
const int ledPin = 8;
const int threshold = 500;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

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

  Serial.println(ldrValue);

  if (ldrValue < threshold) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }

  delay(200);
}
STUCK ON SOMETHING?

Troubleshooting & common fixes.

Robot moves in a straight line and ignores the track.

Check the IR sensors are close enough to the floor (roughly 0.5–1cm) and that both are wired to the correct digital pins.

Robot spins in circles.

Swap the left/right motor wiring — the motors may be connected in reverse of what the code expects.

Works on dark floors but not light ones.

Most IR modules have an onboard potentiometer — turn it slowly while watching the sensor's indicator LED to recalibrate sensitivity for your surface.

WANT GUIDED, HANDS-ON HELP?

Bring this project to life with a mentor.

Loved building this for free? Our instructor-led workshops go deeper with kits, live guidance and more advanced builds.

Plan a Workshop →
KEEP BUILDING

More free workshops.

💡

LED Blinking Using Arduino UNO

Learn how to control an LED using Arduino UNO by making it turn ON and OFF automatically. This is the basic concept behind indicator lights, warning lights, and signal systems used in real-world electronic devices.

View Free Project →
📏

Motion Detection Project

Use a PIR sensor to detect human movement and automatically switch ON an LED. This demonstrates the technology used in security systems, automatic lights, smart homes, and occupancy detection.

View Free Project →
📲

Voice Control LED Using Bluetooth

Control an LED wirelessly using voice commands sent from a smartphone through Bluetooth. This introduces students to wireless control and smart-home applications, such as controlling lights, fans, and other devices remotely.

View Free Project →