Smart Pedestrian Crossing System

Smart Pedestrian Crossing System | Kids Robotics Project with Arduino | MakeMindz
MakeMindz Robotics Project

Build a Smart Pedestrian Crossing System!

A real-world robotics project where you build working traffic lights that stop cars and safely let people cross — with Arduino, LEDs, a buzzer, and a button!

⏱ 2–3 Hours 🎓 Ages 10+ ⚡ Beginner Friendly 🔧 Arduino UNO 💰 Under ₹700
Introduction

Why is This Project Awesome?

Every single day, millions of people cross roads safely because of traffic light systems. But have you ever wondered — how does a crossing know when to stop cars? How does the buzzer know when to beep? That's robotics and electronics at work!

In this project, you'll build your very own Smart Pedestrian Crossing System using an Arduino! When someone presses a button (like a real crossing button), your system will: stop the car traffic (red light on), let the pedestrian cross safely (green walk light + buzzer beeping), then return to normal traffic flow. It's engineering, coding, and problem-solving all in one!

🧠

What you'll learn: How traffic light sequences work, how push-buttons send signals to a microcontroller, how to write timed sequences in Arduino code, and how real-world safety systems are designed!

Step 0 — Gather Supplies

What You Need 🛒

Collect all your parts before you start. Having everything ready makes building much easier and more fun!

Arduino UNO

The brain! Runs all our code and controls the lights.

🔴

2× Red LEDs

One for "Stop" (car side), one for "Don't Walk" (pedestrian side).

🟡

1× Yellow/Amber LED

The "Get Ready" warning light for drivers.

🟢

2× Green LEDs

One for "Go" (car side), one for "Walk" (pedestrian side).

🔔

Piezo Buzzer

Beeps while pedestrians can cross — helps visually impaired people!

🔘

Push Button

The crossing button pedestrians press to request crossing.

🧩

Breadboard

No soldering needed! Plugs everything together easily.

🎛

5× 220Ω Resistors

One for each LED to protect them from burning out.

🎛

1× 10kΩ Resistor

Pull-down resistor for the push button circuit.

🔌

Jumper Wires (25+)

Male-to-male for breadboard connections.

🖥

Computer + USB Cable

To upload code from the free Arduino IDE app.

📦

Small Cardboard Box

Optional! Make a mini road scene to mount everything on.

💰

Total Cost: Around ₹500–₹700 (about $6–$8 USD). An Arduino Starter Kit usually has almost everything you need in one box!

Concept

How It Works 🤔

The system has two sides: the Car Traffic Lights (red, amber, green) and the Pedestrian Lights (red don't-walk, green walk). Here's the flow of what happens when someone presses the crossing button:

🔘

Button Pressed

Pedestrian presses the request button

🟡

Amber Warning

Cars warned to slow down (amber for 3s)

🔴

Cars Stop

Red light stops all car traffic

🟢

Walk + Beep

Green walk light + buzzer beeping for 8s

🔄

Back to Normal

Cars get green light again, system resets

🌟

Real World Connection: Real pedestrian crossings work in exactly this way! The buzzer that beeps faster at real crossings helps blind and visually impaired people know it's safe to cross. Your project includes this feature too!

Traffic Logic

Traffic Light Phases 🚦

Your system has three main phases. Understanding these phases is the key to writing the code!

Phase 1
Normal — Cars Go
Phase 2
Warning — Slow Down
Phase 3
Stop — Pedestrian Crosses

🟢 Phase 1 — Normal Traffic

  • Car Green LED: ON
  • Car Red LED: OFF
  • Pedestrian Red: ON (don't walk)
  • Pedestrian Green: OFF
  • Buzzer: Silent
  • Waiting for button press

🟡 Phase 2 — Amber Warning

  • Car Amber LED: ON (3 seconds)
  • Car Green: OFF
  • Pedestrian Red: still ON
  • Buzzer: Silent
  • Cars must slow down!
  • Duration: 3 seconds

🔴 Phase 3 — Cross Now!

  • Car Red LED: ON
  • Pedestrian Green: ON
  • Pedestrian Red: OFF
  • Buzzer: BEEPING!
  • Duration: 8 seconds
  • Then resets to Phase 1
Electronics

Circuit Diagram & Wiring 🔌

Study this diagram carefully before placing any wires. The two sides — car lights (left) and pedestrian lights + button (right) — both connect to the Arduino in the middle.

Smart Pedestrian Crossing — Full Circuit Diagram MakeMindz.com · Dashed = jumper wires · All LEDs need 220Ω resistors Arduino UNO 5V ● GND ● Pin 2 ● Pin 3 ● Pin 4 ● Pin 5 ● Pin 6 ● Pin 7 ● ● Pin 8 ● GND CAR LIGHTS RED AMB GRN Pin 4 Pin 3 Pin 2 WALK LIGHTS STOP WALK Pin 6 Pin 7 BUZZER Piezo · Pin 5 PUSH BUTTON 10kΩ pulldown · Pin 8 220Ω 220Ω 220Ω 220Ω 220Ω GND Rail (all components) GND Rail Legend: Red LED wires Amber wire Green wires Buzzer wire Button wire GND

Wiring Connection Table

ComponentComponent PinArduino PinResistor Needed
Car Green LEDAnode (+)Pin 2220Ω in series
Car Amber LEDAnode (+)Pin 3220Ω in series
Car Red LEDAnode (+)Pin 4220Ω in series
Buzzer (Positive)+ legPin 5None needed
Pedestrian Red LEDAnode (+)Pin 6220Ω in series
Pedestrian Green LEDAnode (+)Pin 7220Ω in series
Push ButtonOutput legPin 810kΩ to GND
All LED Cathodes (–)Cathode (–)GND
Buzzer Negative– legGND
Button (other leg)Power leg5V
⚠️

Pull-Down Resistor: The 10kΩ resistor connects from the button's output leg to GND. This keeps the input pin at a "LOW" (0V) when the button isn't pressed, preventing random false triggers. Without it, the pin "floats" and gives garbage readings!

Build Instructions

Step-by-Step Build Guide 🔧

Follow these steps in order. Read each step completely before doing it!

1

Download & Set Up Arduino IDE

Go to arduino.cc/en/software and download the free Arduino IDE. Install it, plug in your Arduino UNO with a USB cable, then go to Tools → Board → Arduino UNO and Tools → Port → select your port (looks like COM3 or /dev/tty.usbmodem). You're ready to code!

2

Set Up the Breadboard Power Rails

Connect the breadboard's red (+) power rail to Arduino 5V using a red jumper wire, and the blue (–) rail to Arduino GND using a black wire. These rails power everything on the breadboard — think of them like an electric highway running down both sides of the board!

3

Place the Car Traffic Light LEDs

Push the three car-side LEDs (Green, Amber, Red) into the breadboard with a few rows gap between each. Remember: the longer leg = positive (+) = anode. For each LED, put a 220Ω resistor between the positive leg's row and the wire going to its Arduino pin. Connect negative legs to the GND rail.

4

Place the Pedestrian Signal LEDs

Add the two pedestrian LEDs (Red "Don't Walk" + Green "Walk") to another section of the breadboard. Wire them the same way as the car LEDs with 220Ω resistors. Connect them to Pins 6 and 7 respectively. Keep them physically separate from the car lights — this helps you understand the two sides of the system!

5

Add the Piezo Buzzer

Place the buzzer on the breadboard. Connect the positive (+) leg directly to Pin 5 (no resistor needed for a buzzer). Connect the negative leg to GND. The small + symbol on the buzzer's top tells you which leg is positive. If yours has no marking, the longer leg is typically positive.

6

Wire the Push Button with Pull-Down Resistor

This is the trickiest part! Push the button across the middle gap of the breadboard. Connect one side to 5V. Connect the other side to Pin 8. Also connect that same side (Pin 8 side) through a 10kΩ resistor to GND. This pull-down resistor ensures Pin 8 reads LOW when button isn't pressed.

7

Check Every Connection

Before uploading code, go through each row of the wiring table and verify each connection. The most common mistakes: wrong LED orientation (short leg = negative, always goes to GND), missing resistors, and the button's pull-down resistor connected to the wrong rail. Checking now saves debugging time later!

8

Upload the Code & Test!

Copy the full code from the section below into your Arduino IDE. Click the ✓ button to verify — you should see "Done compiling" with no red errors. Then click → to upload. The Arduino will reset, and within 2 seconds your Car Green LED should light up, meaning the system is in Phase 1 — waiting for a button press!

Arduino Code

The Full Code 💻

Here's the complete, fully commented Arduino code. Every section is explained so you can understand what each part does and modify it yourself!

smart_pedestrian_crossing.ino Arduino C++
// ╔══════════════════════════════════════════════════════╗
// ║   Smart Pedestrian Crossing System                   ║
// ║   MakeMindz Robotics Project                         ║
// ║   Simulates a real-world traffic crossing with       ║
// ║   button, LEDs, and a buzzer for safe crossing!      ║
// ╚══════════════════════════════════════════════════════╝

// ── Pin Definitions ───────────────────────────────────
// Car traffic light pins
const int CAR_GREEN   = 2;
const int CAR_AMBER   = 3;
const int CAR_RED     = 4;

// Buzzer pin
const int BUZZER      = 5;

// Pedestrian signal pins
const int PED_RED     = 6;  // "Don't Walk" red
const int PED_GREEN   = 7;  // "Walk" green

// Push button pin
const int BUTTON      = 8;

// ── Timing Settings (milliseconds) ───────────────────
const int AMBER_TIME  = 3000;  // 3 seconds amber warning
const int CROSS_TIME  = 8000;  // 8 seconds for crossing
const int BUZZ_BEEP   = 400;   // Buzzer beep interval (ms)
const int BUZZ_FREQ   = 880;   // Buzzer frequency (Hz)
const int BUZZ_FAST   = 200;   // Fast beep near end

// ── State Variables ───────────────────────────────────
bool crossingActive = false; // Is crossing in progress?

// ─────────────────────────────────────────────────────
void setup() {
  // Car light pins → output
  pinMode(CAR_GREEN,  OUTPUT);
  pinMode(CAR_AMBER,  OUTPUT);
  pinMode(CAR_RED,    OUTPUT);

  // Pedestrian signal pins → output
  pinMode(PED_RED,    OUTPUT);
  pinMode(PED_GREEN,  OUTPUT);

  // Buzzer → output
  pinMode(BUZZER,     OUTPUT);

  // Button → input (10kΩ pull-down handles this)
  pinMode(BUTTON,     INPUT);

  // Serial monitor for debugging
  Serial.begin(9600);
  Serial.println("🚦 Smart Crossing Ready!");

  // Startup: flash all LEDs twice as a self-test
  startupTest();

  // Begin in Phase 1: Normal traffic flowing
  setNormalTraffic();
}

// ─────────────────────────────────────────────────────
void loop() {
  // Continuously check if the button is pressed
  if (digitalRead(BUTTON) == HIGH && !crossingActive) {
    Serial.println("🔘 Button pressed! Starting crossing...");
    crossingActive = true;
    runCrossingSequence();
    crossingActive = false;
    Serial.println("✅ Crossing complete. Back to normal.");
  }
}

// ─────────────────────────────────────────────────────
// Sets the system to Phase 1: Normal traffic
void setNormalTraffic() {
  digitalWrite(CAR_GREEN,  HIGH);  // Cars GO
  digitalWrite(CAR_AMBER,  LOW);
  digitalWrite(CAR_RED,    LOW);
  digitalWrite(PED_RED,    HIGH);  // Pedestrians WAIT
  digitalWrite(PED_GREEN,  LOW);
  noTone(BUZZER);
  Serial.println("🟢 Phase 1: Normal — Cars green");
}

// ─────────────────────────────────────────────────────
// The main crossing sequence: Phases 2 then 3
void runCrossingSequence() {

  // ── PHASE 2: Amber Warning ──────────────────────────
  Serial.println("🟡 Phase 2: Amber — Cars slow down");
  digitalWrite(CAR_GREEN,  LOW);
  digitalWrite(CAR_AMBER,  HIGH);  // Amber ON
  digitalWrite(CAR_RED,    LOW);
  digitalWrite(PED_RED,    HIGH);  // Pedestrians still WAIT
  digitalWrite(PED_GREEN,  LOW);
  // Single long beep to warn pedestrian crossing starting soon
  tone(BUZZER, 440, 500);
  delay(AMBER_TIME);               // Wait 3 seconds

  // ── PHASE 3: STOP — Pedestrian Crosses ─────────────
  Serial.println("🔴 Phase 3: Red — Pedestrians crossing!");
  digitalWrite(CAR_AMBER,  LOW);
  digitalWrite(CAR_RED,    HIGH);  // Cars STOP
  digitalWrite(PED_RED,    LOW);
  digitalWrite(PED_GREEN,  HIGH);  // Walk sign ON!

  // Beep the buzzer rhythmically for CROSS_TIME
  // Beeps fast during the last 3 seconds (urgency!)
  unsigned long crossStart = millis();
  while (millis() - crossStart < CROSS_TIME) {
    unsigned long timeLeft = CROSS_TIME - (millis() - crossStart);
    int beepInterval = (timeLeft < 3000) ? BUZZ_FAST : BUZZ_BEEP;
    tone(BUZZER, BUZZ_FREQ, beepInterval / 2);
    delay(beepInterval);
  }
  noTone(BUZZER);

  // Brief all-red pause (safety clearance interval)
  Serial.println("⏸  Safety pause — all red");
  digitalWrite(PED_GREEN,  LOW);
  digitalWrite(PED_RED,    HIGH);
  delay(1500);  // 1.5 second clearance

  // Return to Phase 1
  setNormalTraffic();
}

// ─────────────────────────────────────────────────────
// Self-test on startup: blinks all LEDs 2x
void startupTest() {
  int pins[] = {CAR_GREEN, CAR_AMBER, CAR_RED, PED_RED, PED_GREEN};
  for (int j = 0; j < 2; j++) {           // 2 flash rounds
    for (int i = 0; i < 5; i++) digitalWrite(pins[i], HIGH);
    tone(BUZZER, 1000, 100);
    delay(300);
    for (int i = 0; i < 5; i++) digitalWrite(pins[i], LOW);
    delay(300);
  }
}
💡

Cool Code Feature: Notice how the buzzer beeps faster in the last 3 seconds of the crossing? This is exactly what real pedestrian crossings do! It signals to people that the walk time is ending soon. The code uses timeLeft < 3000 to switch to the faster beep interval.

🔁

The Safety Pause: After the walk light ends, there's a 1.5-second "all-red" pause before cars get their green light. This is standard in real traffic engineering — it gives pedestrians who are still crossing a safety buffer before cars move!

Testing

Test Your Crossing 🧪

Run through these tests after uploading to make sure everything is working correctly!

A

Power-On Self Test

When the Arduino powers on, all 5 LEDs should flash twice together, with a short beep each time. If some LEDs don't flash, check their resistors and orientation. Then the Car Green LED stays on — ready for a button press!

B

Button Press Test

Press the button! You should see: Car Amber ON (3 seconds) → Car Red ON + Walk Green ON + buzzer beeping (8 seconds, speeding up at the end) → brief all-red → back to Car Green. If nothing happens, open Serial Monitor to see debug messages.

C

Speed-Up Test

To test faster, temporarily change AMBER_TIME to 1000 and CROSS_TIME to 3000. Upload again and press the button — the full cycle takes about 5 seconds, making it easy to test multiple times. Change back when done!

D

Serial Monitor Debug

Open the Serial Monitor (Tools → Serial Monitor or Ctrl+Shift+M), set baud to 9600. You'll see messages like "Button pressed!", "Phase 2: Amber", "Phase 3: Red". This is exactly how engineers debug real systems!

🐛

Common Problems: LEDs in wrong direction (swap the legs!), button gives random triggers (check the 10kΩ pull-down to GND), wrong COM port selected (try a different port in Tools → Port), or code won't compile (check for copy-paste errors like missing semicolons).

Next Level

Cool Upgrades to Try 🚀

Once your basic crossing works perfectly, level it up with these awesome additions!

  • 📡
    PIR Motion Sensor (Automatic Detection) Replace the button with a PIR sensor! It automatically detects when a person walks up to the crossing and triggers the sequence — no button needed. Wire it to Pin 8 instead of the button.
  • 📺
    LCD Countdown Timer Add an I2C 16×2 LCD display that shows a countdown like "Cross in: 7s" during the walk phase. Connect to Arduino's SDA (A4) and SCL (A5) pins, and use the LiquidCrystal_I2C library.
  • ☀️
    Light-Dependent Resistor (LDR) Night Mode Add an LDR to detect nighttime. When it gets dark, the system automatically extends the crossing time and makes the buzzer louder — just like real crossings that adapt to conditions!
  • 🚗
    Vehicle Counter with IR Sensor Add an IR sensor to count cars passing. If traffic is heavy, the system waits longer before changing lights. This is how adaptive traffic systems work in smart cities!
  • 🏙
    Build a Mini City Diorama Use cardboard, paint, and small toy cars to build a miniature road scene. Mount your electronics on it for an amazing display project for school! Add a second crossing for a full intersection.
  • 📱
    Bluetooth Remote Control Add an HC-05 Bluetooth module so you can trigger the crossing from your phone using a free Bluetooth terminal app. You could even set timers or change the crossing duration wirelessly!
Stay Safe

Safety Tips ⛑️

Electronics are exciting — let's keep the building safe and fun!

🔌
Always unplug before changing wires Never adjust connections while the Arduino is powered. Disconnect USB first!
👁
Never stare at LEDs directly LEDs are bright! Don't look straight into them, especially from close range.
👨‍👩‍👧
Adult supervision for under-12s Have a parent or teacher nearby when building. Two sets of eyes catch more mistakes!
🔥
Always use resistors with LEDs Without a 220Ω resistor, LEDs can burn out instantly from too much current. Don't skip them!
💻
Check code before uploading Always verify (✓) before uploading (→). Uploading broken code won't harm your Arduino, but fixing errors first saves time.
🧼
Keep food and drinks away Spills and electronics are a terrible combination! Build on a clean, dry surface.
You Did It!

You're a Traffic Engineer! 🎉

Congratulations — you've just built a system that real cities rely on to keep people safe! Your Smart Pedestrian Crossing uses the same fundamental logic as the crossings on real roads: timed light sequences, safety buffers, and audio signals for accessibility.

Here's what you're now an expert in:

⚡ Circuit Design

  • Multi-LED wiring
  • Pull-down resistors
  • Breadboard layout

💻 Arduino Coding

  • State machines
  • Timed sequences
  • digitalRead / Write

🏙 Systems Thinking

  • Safety clearance
  • Accessibility design
  • Real-world engineering
🌟

Show It Off! Bring your Smart Pedestrian Crossing to school as a science fair project! You can explain the engineering behind real traffic lights, how accessibility features work (the beeping buzzer!), and even demonstrate it live. Judges love interactive projects!

MakeMindz — Inspiring Young Makers, Builders & Engineers

More projects at makemindz.com · Questions? Drop a comment below!

© 2025 MakeMindz · Arduino is open-source · Build responsibly · Always supervise young makers

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