Emergency Vehicle Priority System with Arduino

Emergency Vehicle Priority System with Arduino - Kids Guide
🚨

Emergency Vehicle Priority System

Build your own smart traffic light that automatically gives ambulances a GREEN light! 🚦

🧒 Kids Friendly 🔧 Arduino Project ⏱️ 2-3 Hours 🌟 Beginner Level
💡

What Will You Build?

You'll create a mini traffic light system using an Arduino microcontroller and a sound sensor. When it detects an ambulance siren, it automatically turns all traffic lights RED and gives the ambulance a clear GREEN path — just like real cities do!

1 How Does It Work?

🔊

Hear the Siren

A sound sensor detects the ambulance's loud siren sound frequency

🧠

Arduino Thinks

The Arduino microcontroller reads the sensor and runs our smart code

🔴🔴

All Stop!

All regular traffic lights switch to RED to stop cars safely

🟢

Ambulance Goes!

The ambulance lane gets a GREEN light and a clear road to speed through

🌍

Fun Fact!

Real cities like Amsterdam and Singapore use systems just like this! Emergency vehicles save 2-3 minutes per journey — and in heart attacks, every minute matters. Your project could help save lives someday!

2 See It In Action! (Simulator)

🎮 Interactive Traffic Simulator

Normal Traffic
🚑
Ambulance Lane

🟢 Normal traffic mode — all lights working normally

3 Parts You Need 🛒

🎛️
Arduino Uno
Quantity: 1 — The brain!
🔴
Red LEDs
Quantity: 3 — Stop lights
🟡
Yellow LEDs
Quantity: 3 — Caution lights
🟢
Green LEDs
Quantity: 3 — Go lights
🔊
Sound Sensor (KY-037)
Quantity: 1 — Hears the siren
220Ω Resistors
Quantity: 9 — Protect LEDs
🧩
Breadboard
Quantity: 1 — No soldering!
🔌
Jumper Wires
Quantity: 20+ — Connect everything
💻
USB Cable + Computer
With Arduino IDE installed
⚠️ Safety First! Always ask a parent or teacher to help you with electronics. Never connect anything to mains electricity — we only use safe USB power from your computer! 😊

4 Circuit Wiring Guide 🔌

🚦 TRAFFIC LIGHT 1 (Lane A — Normal Traffic)
Red LED (+)→ Pin 2with 220Ω resistor
Yellow LED (+)→ Pin 3with 220Ω resistor
Green LED (+)→ Pin 4with 220Ω resistor
All LED (–)→ GNDGround rail
🚑 TRAFFIC LIGHT 2 (Ambulance Lane)
Red LED (+)→ Pin 5with 220Ω resistor
Yellow LED (+)→ Pin 6with 220Ω resistor
Green LED (+)→ Pin 7with 220Ω resistor
All LED (–)→ GNDGround rail
🔊 SOUND SENSOR (KY-037)
VCC pin→ 5VPower
GND pin→ GNDGround
DO pin→ Pin 8Digital signal
AO pin→ A0Analog (optional)
🔧

Wiring Tip for Kids!

Think of resistors like speed bumps for electricity! They slow down the current so your LEDs don't burn out. The long leg of an LED goes to the + pin, and the short leg goes to – (ground). Red wire = power, Black wire = ground!

5 Upload Steps 📲

1

Download Arduino IDE

Go to arduino.cc and download the free Arduino software for your computer (Windows, Mac, or Linux all work!).

2

Plug in your Arduino

Connect your Arduino Uno to your computer using the USB cable. The power light should turn ON — that means it's working!

3

Select the right board

In Arduino IDE, click Tools → Board → Arduino Uno. Then click Tools → Port and select the COM port that appeared.

4

Copy & paste the code

Copy the code from Section 6 below and paste it into the big white area in Arduino IDE.

5

Verify (Check for errors)

Click the ✔️ checkmark button. If it says "Done compiling" — great! Ask an adult to help if there's an error.

6

Upload to Arduino!

Click the → arrow (Upload) button. The lights on your Arduino will blink fast — the code is loading!

7

Test it!

Clap loudly near the sound sensor or make a siren sound — watch the traffic lights respond! Adjust the blue dial on the sensor to change sensitivity.

6 The Arduino Code 💻

Every line has a comment (the grey text with //) explaining what it does!

// ============================================ // 🚨 EMERGENCY VEHICLE PRIORITY SYSTEM // For Kids! Learn Arduino + save lives 🚑 // ============================================ // --- PIN SETUP for Traffic Light A (Normal) --- const int redA = 2; // Red LED for normal traffic const int yellowA = 3; // Yellow LED for normal traffic const int greenA = 4; // Green LED for normal traffic // --- PIN SETUP for Traffic Light B (Ambulance) --- const int redB = 5; // Red LED for ambulance lane const int yellowB = 6; // Yellow LED for ambulance lane const int greenB = 7; // Green LED for ambulance lane // --- SOUND SENSOR --- const int soundPin = 8; // KY-037 digital output pin // --- TIMING --- int normalDelay = 3000; // Normal phase: 3 seconds int emergencyHold = 8000; // Keep ambulance green for 8 seconds // ============================================ // SETUP — Runs ONCE when Arduino turns on void setup() { pinMode(redA, OUTPUT); pinMode(yellowA, OUTPUT); pinMode(greenA, OUTPUT); pinMode(redB, OUTPUT); pinMode(yellowB, OUTPUT); pinMode(greenB, OUTPUT); pinMode(soundPin, INPUT); Serial.begin(9600); Serial.println("System Ready! Listening for sirens..."); } // ============================================ // LOOP — Runs FOREVER (normal traffic cycle) void loop() { if (digitalRead(soundPin) == HIGH) { Serial.println("🚨 EMERGENCY DETECTED! Clearing the road!"); emergencyProtocol(); return; } // PHASE 1: Lane A gets GREEN setLight(redA, yellowA, greenA, LOW, LOW, HIGH); setLight(redB, yellowB, greenB, HIGH, LOW, LOW); waitAndCheck(normalDelay); // PHASE 2: Yellow warning for Lane A setLight(redA, yellowA, greenA, LOW, HIGH, LOW); waitAndCheck(1500); // PHASE 3: Lane B gets GREEN setLight(redA, yellowA, greenA, HIGH, LOW, LOW); setLight(redB, yellowB, greenB, LOW, LOW, HIGH); waitAndCheck(normalDelay); // PHASE 4: Yellow warning for Lane B setLight(redB, yellowB, greenB, LOW, HIGH, LOW); waitAndCheck(1500); } // ============================================ // EMERGENCY FUNCTION — activates on siren! void emergencyProtocol() { // Flash yellow on ALL lights as warning for (int i = 0; i < 3; i++) { setLight(redA, yellowA, greenA, LOW, HIGH, LOW); setLight(redB, yellowB, greenB, LOW, HIGH, LOW); delay(400); allOff(); delay(200); } // All normal traffic RED, ambulance GREEN! setLight(redA, yellowA, greenA, HIGH, LOW, LOW); setLight(redB, yellowB, greenB, LOW, LOW, HIGH); Serial.println("🟢 AMBULANCE LANE IS CLEAR!"); delay(emergencyHold); Serial.println("✅ Resuming normal traffic."); } // HELPER: Set a traffic light state void setLight(int r, int y, int g, int rv, int yv, int gv) { digitalWrite(r, rv); digitalWrite(y, yv); digitalWrite(g, gv); } // HELPER: Turn all LEDs off void allOff() { for (int p = 2; p <= 7; p++) digitalWrite(p, LOW); } // HELPER: Wait but keep checking for sirens! void waitAndCheck(int ms) { int elapsed = 0; while (elapsed < ms) { if (digitalRead(soundPin) == HIGH) { emergencyProtocol(); return; } delay(50); elapsed += 50; } }

7 Questions Kids Ask 🙋

❓ Why do ambulances need a green light so fast?
When someone is having a heart attack, every minute matters. Studies show that for every minute without treatment, survival chances drop by about 10%. Saving just 2 minutes can make a huge difference!
❓ What if a car horn triggers it by mistake?
Great question! You can adjust the sensitivity dial on the KY-037 sensor so only very loud, high-pitched sounds trigger it. Real city systems use frequency analysis or IR sensors to be even more accurate.
❓ Can I add more traffic lights?
Yes! The Arduino Uno has 13 digital pins, so you can control up to 4 traffic lights (4 × 3 = 12 pins + 1 for sensor). For even more, use an Arduino Mega with 54 digital pins!
❓ How do real city traffic systems work?
Real systems use GPS tracking in the ambulance, infrared transmitters, or 4G/5G networks. The ambulance sends a signal to a central server, which remotely changes all lights along the entire route!

8 Make It Even Cooler! 🚀

📺

Add LCD Screen

Show a message like "EMERGENCY!" when the ambulance is detected

🔔

Buzzer Warning

Add a buzzer that beeps when switching to emergency mode

🌡️

IR Sensor

Use an infrared sensor instead — more accurate than sound alone

📱

WiFi Alert

With ESP8266 module, send a phone notification when triggered!

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