Project 2 : Interactive Traffic Light

Introduction

Interactive Traffic Light is a traffic light combination of standard traffic light for vehicles and traffic light for pedestrians.

Component Used

  1. Breadboard 8.5x5.5cm (400 Holes)

  2. 40-Way 10cm Dupont Jumper Wire

  3. LED 5mm Green x2       

  4. LED 5mm Yellow x1

  5. LED 5mm Red x2

  6. Resistor 0.25W 5% (220R) x5

Objective

In this project we will apply the 2 lessons which we have learned previously in:
1. Lesson 1: LED Blink
2. Lesson 4: Digital Input

 

 

Code

 

Result

At start/normal condition, green LED (vehicle) and red LED (pedestrian) will light up. When push button is pressed, green LED (vehicle) will turn off and yellow LED (vehicle) will turn on for 2 seconds. After that, yellow LED (vehicle) will turn off and red LED (vehicle) will light up. After 1 second, when it is time for pedestrians to cross the road, green LED (pedestrian) will turn on for 5 seconds. Then, green LED (pedestrian) will turn off and red LED (pedestrian) will turn on. After 1 second, it will back to normal condition.

Hardware Components