Skip to content

sablejr/TrafficLight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TrafficLight

Arduino project using an HC-SR04 ultrasonic sensor to control a 3-LED stoplight and a passive buzzer based on object distance.

This project demonstrates:

  • Digital I/O control
  • Passive buzzer PWM/tone control
  • Real-time distance measurement
  • Modular code and clean embedded design
  • Simple distance-based alert system

Hardware Required

  • Arduino UNO R3
  • HC-SR04 Ultrasonic Sensor
  • 1 × Green LED
  • 1 × Yellow LED
  • 1 × Red LED
  • 3 × 220Ω Resistors
  • 1 × Passive Buzzer
  • Breadboard & Jumper Wires

Pin Configuration

Component Arduino Pin
Green LED 7
Yellow LED 6
Red LED 5
Passive Buzzer 2
HC-SR04 TRIG 9
HC-SR04 ECHO 10
GND GND

Wiring Diagram

  • Green LED → Pin 7 → 220Ω resistor → GND
  • Yellow LED → Pin 6 → 220Ω resistor → GND
  • Red LED → Pin 5 → 220Ω resistor → GND
  • Passive Buzzer → Pin 2 → GND
  • HC-SR04: VCC → 5V, GND → GND, TRIG → 9, ECHO → 10

How It Works

  • Distance > 20 cm → Green LED ON, buzzer silent
  • Distance 10–20 cm → Yellow LED ON, medium beep
  • Distance < 10 cm → Red LED ON, fast beep

The buzzer frequency increases as the object gets closer, creating a real-time proximity alert system.

// (Paste your final TrafficLight.ino code here)

About

Arduino 3-LED stoplight with passive buzzer using HC-SR04 ultrasonic sensor for real-time distance alerts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages