You are on page 1of 6

DIRE DAWA UNIVERSITY

INSTITUTE OF TECHNOLOGY
SCHOOL OF ELECTRICAL AND COMPUTER ENGINEERING
INDUSTRIAL CONTROL CHAIR
Project on Embedded System

Title: FINITE STATE MACHINE BASED INTELLIGENT TRAFFIC


LIGHT USING ARDUINO.

NO. GROUP MEMBERS ID NO

1. HABTAMU ABERA 1002164

2. ELIAS MAMO 1002497

3. ASTER DECHASA 1002223


5. MEKDES

ABYU 1002245

6 HABTAMU ABEBE 1002610


ABOUT THIS PROJECT
In this post, we are going to learn about how to make an Arduino traffic light controller. This
traffic light controller will be used to control the flow of traffic. These can be applied at high
traffic areas to avoid traffic blocks or accidents.
The main part of this project is the Arduino which will control the LEDs and their timings to
guide the vehicles.

Components Required for Arduino Traffic Light Controller


 Arduino Uno
 Red LEDs (4 pieces)
 Yellow LEDs (4 pieces)
 Green LEDs (4 pieces)
 220 ohm resistors (12 pieces)
Working Principle of Arduino traffic light
controller.
At start, green light of signal 1, 4 red lights at 2 and 3 signals will light up to give time to the
vehicles at signal 1 and 4 to pass.
After 5 seconds, the yellow light at all signal will light up to give an indication that the red light
at signal 1 and 4 are about to come up and also to give an indication to the vehicles at signal 2
and 3 that the green light is about to light up.
So after 2 seconds, red light at signal 1 and 4 will come up and green light at signal 2 and 3 will
come up meaning vehicles at signal 1 and 4 must stop and vehicles at signal 2 can move.
Similarly the traffic light controller will work for the signal 3, signal 4 and the system will keep
looping.

Circuit Diagram for Arduino Traffic Light Controller


There are total of 12 LEDs used in this project. Each signal has 3 LEDs (Red, Yellow and Green)
connected to it through the 220 ohm resistors.
The resistors are used to limit the current that is going to pass through the LEDs. If you won’t
use the resistors then the LEDs may burn due to excessive current.
Code for Arduino 4 way Traffic Light Controller
First of all, we initialized four arrays for the signal pins and defined the pins where we have connected the
LEDs.

int signal1[] = {13, 12, 11}; // signal 1 Red, Yellow and Green

int signal2[] = {10, 9, 8}; // signal 2 Red, Yellow and Green

int signal3[] = {7, 6, 5}; // signal 3 Red, Yellow and Green

int signal4[] = {4, 3, 2}; // signal 4 Red, Yellow and Green

int redDelay = 5000;

int yellowDelay = 2000;

int greenDelay = 5000;

void setup()

// Declaring all the LED's as output

for (int i = 0; i < 3; i++)

pinMode(signal1[i], OUTPUT);

pinMode(signal2[i], OUTPUT);

pinMode(signal3[i], OUTPUT);

pinMode(signal4[i], OUTPUT);

for (int i = 0; i < 3; i++)

digitalWrite(signal1[i], LOW);

digitalWrite(signal2[i], LOW);

digitalWrite(signal3[i], LOW);
digitalWrite(signal4[i], LOW);

void loop()

// Making GREEN LED at signal 1,4 and RED LED's at 2 and 3 signal HIGH

digitalWrite(signal1[2], HIGH);

digitalWrite(signal4[2], HIGH);

digitalWrite(signal1[0], LOW);

digitalWrite(signal2[0], HIGH);

digitalWrite(signal3[0], HIGH);

digitalWrite(signal4[0], LOW);

delay(redDelay);

// Making Green LED at signal 1,4 LOW and making yellow LED at all signal HIGH for 2
seconds

digitalWrite(signal1[2], LOW);

digitalWrite(signal4[2], LOW);

digitalWrite(signal1[1], HIGH);

digitalWrite(signal2[1], HIGH);

digitalWrite(signal3[1], HIGH);

digitalWrite(signal4[1], HIGH);

delay(yellowDelay);

digitalWrite(signal1[1], LOW);

digitalWrite(signal2[1], LOW);

digitalWrite(signal3[1], LOW);
digitalWrite(signal34[1], LOW);

// Making Green LED at signal 2,3 and red LED's at 1 and 4 signal HIGH

digitalWrite(signal2[2], HIGH);

digitalWrite(signal3[2], HIGH);

digitalWrite(signal1[0], HIGH);

digitalWrite(signal2[0], LOW);

digitalWrite(signal3[0], LOW);

digitalWrite(signal4[0], HIGH);

delay(redDelay);

// Making Green LED at signal 2,3 LOW and making yellow LED for all signal HIGH for 2
seconds

digitalWrite(signal2[2], LOW);

digitalWrite(signal3[2], LOW);

digitalWrite(signal1[1], HIGH);

digitalWrite(signal2[1], HIGH);

digitalWrite(signal3[1], HIGH);

digitalWrite(signal4[1], HIGH);

delay(yellowDelay);

digitalWrite(signal1[1], LOW);

digitalWrite(signal2[1], LOW);

digitalWrite(signal3[1], LOW);

digitalWrite(signal4[1], LOW);

You might also like