Smart Road Light System: A DIY Vehicle-Triggered Streetlight Model with Arduino | Kids Robotics Project

Smart Road Light System: A DIY Vehicle-Triggered Streetlight Model with Arduino | Kids Robotics Project
Robotics Project · Ages 9+

The Smart Road Light System: streetlights that switch on only when a car actually passes

A miniature road model lined with tiny streetlights that stay dark and quiet — until a toy car rolls underneath. Then, and only if it's "night" on the model, that one light switches on automatically, and switches back off a few seconds after the road is clear again.

What you're building

A miniature "smart city" road that teaches sensing, automation, and energy-saving logic.

The Smart Road Light System is a small road model with a row of streetlight posts along it. Underneath the road, hidden IR sensors watch for anything passing overhead — a toy car, a marble, or a finger. A light sensor keeps track of whether it's "day" or "night" on the model. Put the two together, and each streetlight only switches on when it's dark and a vehicle is actually detected nearby, then automatically switches off again once the road is clear — just like real energy-saving smart streetlights.

Night Sensing

A light sensor checks whether it's dark enough on the model road for streetlights to matter.

Vehicle Detection

IR sensors under the road spot a passing vehicle at each streetlight zone.

Auto Streetlight

Each streetlight switches on only when needed, and off again once the road is empty.

☀️ DaytimeAll streetlights stay off, no matter what
💡 Night + VehicleThat zone's streetlight switches on
🌙 Night, Empty RoadLights stay off until a vehicle arrives

Materials list

Most electronics can be reused from a beginner Arduino sensor kit.

Electronics

  • 1x Arduino Uno
  • 1x LDR (light sensor) module
  • 4x IR obstacle sensor modules (one per streetlight zone)
  • 4x LEDs (streetlights) + 220-ohm resistors
  • 1x 16x2 LCD display with I2C backpack
  • Jumper wires + breadboard
  • Small USB power bank or 9V adapter

Road model & build supplies

  • Foam board or cardboard base (road diorama)
  • Gray paint or gray paper (road surface)
  • Small toy cars
  • Thin wooden dowels or straws (lamp posts)
  • Hot glue gun
  • Craft knife (adult use only)
  • Black paper or fabric (to darken the model for "night" testing)

Circuit diagram

One light sensor decides day or night, and four IR sensors each control their own streetlight.

ARDUINO UNO USB / 5V power in LDR SENSOR Day / night Signal → A0 IR SENSOR 1 Zone 1 D2 IR SENSOR 2 Zone 2 D3 IR SENSOR 3 Zone 3 D4 IR SENSOR 4 Zone 4 D5 STREETLIGHTS 4x LEDs D6, D7, D8, D9 16x2 LCD (I2C) Status display SDA → A4 SCL → A5 5V POWER USB or battery

Tip: Space the IR sensors evenly under the road, each lined up beneath its own streetlight post, so a car passing over one sensor only lights up the lamp right above it. Keep all grounds connected together.

Wiring reference table

ComponentComponent PinArduino Pin
LDR Light SensorSignal (AO)A0
IR Sensor — Zone 1SignalD2
IR Sensor — Zone 2SignalD3
IR Sensor — Zone 3SignalD4
IR Sensor — Zone 4SignalD5
Streetlight LED — Zone 1AnodeD6
Streetlight LED — Zone 2AnodeD7
Streetlight LED — Zone 3AnodeD8
Streetlight LED — Zone 4AnodeD9
16x2 LCD (I2C)SDA / SCLA4 / A5
All componentsGNDCommon GND rail

Step-by-step build instructions

Work through these in order — test the sensors on the bench before mounting anything on the road model.

  1. Build the road base

    Cut a long foam board or cardboard strip, paint or cover it gray to look like a road, and mark out four evenly spaced streetlight positions along one edge.

  2. Wire the LDR light sensor

    Connect the LDR module's signal pin to A0, and check that its reading changes clearly between a bright room and a covered, dark test.

  3. Wire the four IR sensors

    Connect each IR obstacle sensor's signal pin to D2 through D5, and test each one by passing a hand or toy car over it to confirm it reads correctly.

  4. Wire the four streetlight LEDs

    Connect each LED (with a resistor) to D6 through D9, matching each one to the IR sensor for the same zone.

  5. Add the LCD status display

    Connect the 16x2 LCD's SDA/SCL to A4/A5 so you can see whether the model thinks it's day or night, and which zones are active.

  6. Mount the sensors and lamp posts

    Fix each IR sensor just under the road surface at its marked position, and glue a small lamp post with an LED on top directly above it.

  7. Upload the code and calibrate

    Upload the sketch below, then adjust NIGHT_THRESHOLD in the code until the LCD correctly shows "Night" when the model is covered or the room is dim.

  8. Test with a toy car

    Darken the model, then roll a toy car slowly along the road and watch each streetlight switch on as the car passes, and switch off again a few seconds after it moves on.

Arduino code

Copy this into a new sketch in the Arduino IDE. Install the LiquidCrystal_I2C library first from the Library Manager.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// ---- Pin setup ----
#define LDR_PIN        A0
const int irPins[4]  = {2, 3, 4, 5};
const int ledPins[4] = {6, 7, 8, 9};

LiquidCrystal_I2C lcd(0x27, 16, 2);

int NIGHT_THRESHOLD = 500;              // calibrate for your LDR and room
const unsigned long HOLD_TIME = 4000;   // keep light on 4s after last detection
unsigned long lastSeen[4] = {0, 0, 0, 0};
int activeZones = 0;

void setup() {
  for (int i = 0; i < 4; i++) {
    pinMode(irPins[i], INPUT);
    pinMode(ledPins[i], OUTPUT);
    digitalWrite(ledPins[i], LOW);
  }

  lcd.init();
  lcd.backlight();
}

void loop() {
  int lightLevel = analogRead(LDR_PIN);
  bool isNight = lightLevel < NIGHT_THRESHOLD;

  activeZones = 0;

  for (int i = 0; i < 4; i++) {
    bool vehicleDetected = digitalRead(irPins[i]) == LOW; // LOW = beam broken

    if (isNight && vehicleDetected) {
      lastSeen[i] = millis();
    }

    bool shouldBeOn = isNight && (millis() - lastSeen[i] < HOLD_TIME);
    digitalWrite(ledPins[i], shouldBeOn ? HIGH : LOW);

    if (shouldBeOn) {
      activeZones++;
    }
  }

  updateDisplay(isNight);
  delay(100);
}

void updateDisplay(bool isNight) {
  lcd.setCursor(0, 0);
  lcd.print(isNight ? "Night Mode      " : "Daytime - Off   ");

  lcd.setCursor(0, 1);
  lcd.print("Lights on: ");
  lcd.print(activeZones);
  lcd.print("    ");
}

Beginner tip

If a light seems to flicker as a car passes, increase HOLD_TIME slightly so the light stays on smoothly for the full time the car is near that zone.

Safety notes for young makers

Ask an adult to help with wiring and soldering. Keep LED wiring neat and away from moving toy cars so nothing snags, and always use resistors with LEDs to keep them from burning out.

Why this project works so well for learning

The Smart Road Light System introduces one of the most useful ideas in real automation: only turning something on when it's actually needed. Combining a light sensor with motion sensors teaches how to layer two conditions together in code, using AND logic, rather than reacting to just one signal. Using millis() to keep each light on for a few seconds after detection, instead of switching off instantly, is a gentle first look at timing-based behavior — the same idea real smart streetlights use to save energy across entire cities.

Frequently asked questions

What age group is this robotics project best suited for?

Ages 9 and up can build this with an adult helping on wiring. Ages 12+ with some Arduino experience can usually manage most of it independently, including the calibration step.

Do I need to know how to code to build this?

No. The code above uploads and runs as-is. The one hands-on coding step is adjusting NIGHT_THRESHOLD during calibration, which is a great first edit for a beginner.

Can I build this with fewer or more streetlights?

Yes. Just add or remove entries from the irPins and ledPins arrays at the top of the code, and connect the matching sensors and LEDs to those pins.

Why do the lights stay on for a few seconds after the car passes?

Without a short hold time, the light would flicker on and off rapidly as the car moves past the sensor's detection zone. The HOLD_TIME value smooths that out, just like real motion-activated lights.

Can I make it react to real cars outside instead of a model?

Not directly with this build — it's designed and calibrated for a small tabletop model. A real outdoor version would need weatherproof sensors, mains-rated lighting, and adult electrical expertise well beyond this project.

Built for curious young engineers. Always build and power on electronics with adult supervision.

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
★★★★★ Young inventors love it!
🖨️
3D Print
All parts
⚡
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 ₹300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
★★★★★ Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 ₹200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course