You are on page 1of 20

INTER DEPARTMENT PROJECT REPORT ON

Density Based Traffic Light Controller Using Arduino


Submitted

By

Aman Kumar V Sravani


191FA04581 191FA05206

Ramkrishna Mahto S Vamsi


191FA04584 191FA05205

Kshitij Chanikya
191FA4595 191FA05181

Under the guidance of

Ms Pushya Chaprala, ( Assistant Professor, CSE )

Mr S. Vishnu, ( Assistant Professor, ECE)

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


VIGNAN'S FOUNDATION FOR SCIENCE, TECHNOLOGY AND RESEARCH Deemed to
be UNIVERSITY
Vadlamudi, Guntur.

~I~
VIGNAN’S FOUNDATION FOR SCIENCE TECHNOLOGY AND RESEARCH

Deemed to be UNIVERSITY

VADLAMUDI, GUNTUR DIST, ANDHRA PRADESH, INDIA, PIN-522 213

CERTIFICATE

This is to certify that the Inter Department Project Report entitled “Density Based Traffic Light
Controller Using Arduino” that is being submitted by Aman Kumar (191FA04581), Kshitij
(191FA04595), Ramkrishna Mahto(191FA04584) in association with V Sravani (191FA05206),
S Vamsi (191FA05205), Chanikya (191FA05181) in partial fulfilment of Inter Department Project
course work is a bonafide work carried under the supervision of Ms Pushya Chaprala mam,
Designation from Department of Computer Science & Engineering.

Ms Pushya Chaprala Mr S . Vishnu Dr.T.Pitchaiah Dr.VenkatesuluDondeti


Assistant Professor Assistant Professor ME,Ph.D,MIEEE HOD,ECE HOD, CSE

For the External Inter Department Project Vive-voce scheduled on 24-06-2022.

Internal Examiner External Examiner

~ II ~
DECLARATION

We hereby declare that the Inter Department Project entitled Density Based Traffic Light Controller
Using Arduino is being submitted by Aman Kumar (191FA04581), Kshitij (191FA04595),
Ramkrishna Mahto(191FA04584) in partial fulfillment of Inter Department Project course work.
This dissertation is our original work, and the project has not formed the basis for the award of any
degree. We have worked in association with V Sravani (191FA05206), S Vamsi (191FA05205),
Chanikya (191FA05181) under the supervision of Guide Name, Designation from Department of
Computer Science & Engineering

By
Aman Kumar (191FA04581)
Ramkrishna Mahto (191FA04584)
Kshitij (191FA4595)
V Sravani (191FA05206)
S Vamsi (191FA05205)
Chanikya (191FA05181)

~ III ~
TABLE OF CONTENTS

1. PROBLEM STATEMENT ............................................................................................. 5


2. OBJECTIVE ..................................................................................................................... 6
3. INTRODUCTION ............................................................................................................ 7
4.CIRCUIT DIAGRAM ........................................................................................................8
5. HARDWARE REQUIREMENT..................................................................................... 9
6. SOFTWARE REQUIREMENT ...................................................................................... 11
7. WORKING ........................................................................................................................ 13
8. CODE ................................................................................................................................. 14
9. ADVANTAGES ................................................................................................................ 19
10. CONCLUSION ................................................................................................................ 20

~ IV ~
PROBLEM STATEMENT

This project is aimed with the purpose of reducing the traffic tensions in the society at various cities
thus moving towards a no accident prone environment which would eradicate accidents caused due
to reckless or substance induced driving. Traffic Density is a serious problem in most cities
therefore we need to change the control from manual to time clock based system. We use Arduino
nano to program a command for 4 way directional control. The traffic lights are modified to switch
on only at that exact moment until and unless an infrared signal comes into its vicinity. The sensor
here is placed at a certain distance to optimise the flow of the density of traffic to maintain a proper
traffic light control system ta particular junction. Once there is no sign identified by any of the four
sensors the traffic lights keep on dealing with an auspicious premise. The approximate mean
response time was found to be around 0.41 seconds. However further experiment conduction would
help us use it in real life situations.

~V~
OBJECTIVE

The main purpose of this project is, if there will be no traffic on the other signal, one shouldn’t wait
for that signal. The system will skip that signal and will move on the next one.

If there is traffic at all the signals, then the system will work normally by controlling the signals one
by one.

If there is no traffic near a signal, then the system will skip this signal and will move on to the next
one. For example, if there is no vehicle at signal 2, 3 and currently the system is allowing vehicles
at signal 1 to pass. Then after signal 1, the system will move on to signal 4 skipping signal 2 and 3.
If there is no traffic at all the 4 signals, system will stop at the current signal and will only move on
the next signal if there will be traffic at any other signal.

~ VI ~
INTRODUCTION

This project aims to improve the efficiency of traffic light system using Arduino based model. The
traffic determination is done by IR sensors on each path. Using the details provided by the IR
sensor we can guide the traffic signal to work efficiently with the traffic flow. The traffic density on
each road determines the change of the timing of the signal. The road with the least traffic is
assigned with the red signal and the one with the most traffic is assigned the green signal. In this
project we imply the use if IR sensor to wok accordingly with Arduino to provide a better and
efficient traffic light control system. We propose this paper with the idea of improving the traffic
light system resulting in reducing the jamming level henceforth eradicating the problems like loss
of fuel, energy dissipation, pollution and time loss. For the betterment of the nation the necessity to
improve the traffic light system is very much necessary. The programming for the easy change in
traffic light will result in the better movement of vehicles resulting in safe and easy floe of traffic
density. This will also help to reduce major accidents like car crashes caused due to confusion of
traffic lights due to the drivers and also problems caused due to trespassing of lanes .This system
can be helpful to provide better traffic control in urban cities.

~ VII ~
CIRCUIT DIAGRAM

~ VIII ~
HARDWARE REQUIRMENT

1) Arduino Mega 2560


2) 4 X HC-SR04 ultrasonic sensors
3) 4 X Red LEDs
4) 4 X Green LEDs
5) 4 X Yellow LEDs
6) 12 X 220 ohm resistors
7) Jumper cables
8) Breadboards

1) Arduino Mega 2560 :-


The Arduino Mega 2560 is a microcontroller board based on the 2560 .It
has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4
UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an
ICSP header, and a reset button. It contains everything needed to support the microcontroller;
simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to
get started. The Mega 2560 board is compatible with most shields designed for the Uno and the
former boards Duemilanove or Diecimila.

2) HC-SR04 Ultrasonic Sensors :-


An ultrasonic sensor is an electronic device that measures the distance of a
target object by emitting ultrasonic sound waves, and converts the reflected sound into an electrical
signal. Ultrasonic waves travel faster than the speed of audible sound (i.e. the sound that humans
can hear). Ultrasonic sensors have two main components: the transmitter (which emits the sound
using piezoelectric crystals) and the receiver (which encounters the sound after it has travelled to
and from the target).
In order to calculate the distance between the sensor and the object, the sensor measures the time it
takes between the emission of the sound by the transmitter to its contact with the receiver. The
formula for this calculation is D = ½ T x C (where D is the distance, T is the time, and C is the
speed of sound ~ 343 meters/second). For example, if a scientist set up an ultrasonic sensor aimed

~ IX ~
at a box and it took 0.025 seconds for the sound to bounce back, the distance between the ultrasonic
sensor and the box would be:

3) LED Light :-
LED stands for light emitting diode. LED lighting products produce light up to 90%
more efficiently than incandescent light bulbs. How do they work? An electrical current passes
through a microchip, which illuminates the tiny light sources we call LEDs and the result is visible
light.

4) Resistors :-
A resistor is an electrical component that limits or regulates the flow of electrical
current in an electronic circuit. Resistors can also be used to provide a specific voltage for an active
device such as a transistor.

5) Breadboards :-
Breadboards are one of the most fundamental pieces when learning how to build circuits.
In this tutorial, you will learn a little bit about what breadboards are, why they are called
breadboards, and how to use one. Once you are done you should have a basic understanding of how
breadboards work and be able to build a basic circuit on a breadboard.

6) Jumper cables :-
A jump wire (also known as jumper, jumper wire, DuPont wire) is an electrical wire,
or group of them in a cable, with a connector or pin at each end (or sometimes without them –
simply "tinned"), which is normally used to interconnect the components of a breadboard or other
prototype or test circuit, internally or with other equipment or components, without soldering.

~X~
SOFTWARE REQUIRMENT

1) Arduino IDE
2) Proteus 8 Professional

1) Arduino IDE :-
The open-source Arduino Software (IDE) makes it easy to write code and upload it
to the board. This software can be used with any Arduino board.

 It save the code with extension of .ino.


 It supports c/c++ languages.

2) Proteus 8 Professional :-
The Proteus Design Suite is a proprietary software tool suite used primarily
for electronic design automation. The software is used mainly by electronic design engineers and
technicians to create schematics and electronic prints for manufacturing printed circuit boards.
It was developed in Yorkshire, England by Labcenter Electronics Ltd and is available in English,
French, Spanish and Chinese languages.

~ XI ~
~ XII ~
Working of Density Based Traffic Light Controller Using Arduino

The working of the project is divided into three steps


 If there is traffic at all the signals, then the system will work normally by controlling the signals
one by one.
 If there is no traffic near a signal, then the system will skip this signal and will move on to the
next one. For example, if there is no vehicle at signal 2, 3 and currently the system is allowing
vehicles at signal 1 to pass. Then after signal 1, the system will move on to signal 4 skipping
signal 2 and 3.
 If there is no traffic at all the 4 signals, system will stop at the current signal and will only move
on the next signal if there will be traffic at any other signal.

~ XIII ~
CODE EXPLANATION
 First of all, we included the timezone library. This library is used to repetitively measure a period of time
in microseconds and at the end of each period, an interrupt function will be called.
 We have used this library because we want to read from the sensors and control LED’s at the same time.
We will have to use the delay in between the traffic signal so we can’t read from the sensors
continuously. Therefore we have used this library which will allow us to call a function in which we will
read from the sensors continuously and in the loop function, we will control the traffic signals.
 In the setup function, we have used the Timer1.initialize(microseconds) function. This must be
called before you use any of the other methods of timerone library. “Microseconds” is actually
the period of time the timer takes. It is optionally to specify the timer’s period here. The default
period is 1 second. Keep in mind that it breaks analogWrite() on digital pins 9 and 10.
 Timer1.attachInterrupt(softInterr) calls a function each time the timer period finishes. We have
set the timer period at 100000 so our function will be called after 100 milli seconds.
 In the loop function it is looking if there is any vehicles under the 5 cm distance or not. If there
will be vehicle, then the function to that signal will be called.

SOURCE CODE :-

#include<TimerOne.h>
int signal1[] = {23, 25, 27};
int signal2[] = {46, 48, 50};
int signal3[] = {13, 12, 11};
int signal4[] = {10, 9, 8};
int redDelay = 5000;
int yellowDelay = 2000;
volatile int triggerpin1 = 31;
volatile int echopin1 = 29;
volatile int triggerpin2 = 44;
volatile int echopin2 = 42;
volatile int triggerpin3 = 7;
volatile int echopin3 = 6;
volatile int triggerpin4 = 5;

~ XIV ~
volatile int echopin4 = 4;
volatile long time;
volatile int S1, S2, S3, S4;
int t = 5;
void setup(){
Serial.begin(115200);
Timer1.initialize(100000); "microseconds" is the period of time the timer takes.
Timer1.attachInterrupt(softInterr); //Run a function each time the timer period finishes.
for(int i=0; i<3; i++){
pinMode(signal1[i], OUTPUT);
pinMode(signal2[i], OUTPUT);
pinMode(signal3[i], OUTPUT);
pinMode(signal4[i], OUTPUT);
}
void loop()
{
if(S1<t)
{
signal1Function();
}
if(S2<t)
{
signal2Function();
}
if(S3<t)
{
signal3Function();
}
if(S4<t)
{
signal4Function();
}
}
{

~ XV ~
digitalWrite(triggerpin1, LOW);
delayMicroseconds(2);
digitalWrite(triggerpin1, HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin1, LOW);
time = pulseIn(echopin1, HIGH);
S1= time*0.034/2;
digitalWrite(triggerpin2, LOW);
delayMicroseconds(2);
digitalWrite(triggerpin2, HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin2, LOW);
time = pulseIn(echopin2, HIGH);
S2= time*0.034/2;
digitalWrite(triggerpin3, LOW);
delayMicroseconds(2);
digitalWrite(triggerpin3, HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin3, LOW);
time = pulseIn(echopin3, HIGH);
S3= time*0.034/2;
digitalWrite(triggerpin4, LOW);
delayMicroseconds(2);
digitalWrite(triggerpin4, HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin4, LOW);
time = pulseIn(echopin4, HIGH);
S4= time*0.034/2;
Serial.print("S1: ");
Serial.print(S1);
Serial.print(" S2: ");
Serial.print(S2);
Serial.print(" S3: ");
Serial.print(S3);

~ XVI ~
Serial.print(" S4: ");
Serial.println(S4);
}
void signal1Function()
{
Serial.println("1");
low();
digitalWrite(signal1[0], LOW);
digitalWrite(signal1[2], HIGH);
delay(redDelay);
if(S2<t || S3<t || S4<t)
{
digitalWrite(signal1[2], LOW);
digitalWrite(signal1[1], HIGH);
delay(yellowDelay);
}
}
void signal2Function()
{
Serial.println("2");
low();
digitalWrite(signal2[0], LOW);
digitalWrite(signal2[2], HIGH);
delay(redDelay);
if(S1<t || S3<t || S4<t)
{
digitalWrite(signal2[2], LOW);
digitalWrite(signal2[1], HIGH);
delay(yellowDelay);
}
}
void signal3Function()
{
Serial.println("3");

~ XVII ~
low();
digitalWrite(signal3[0], LOW);
digitalWrite(signal3[2], HIGH);
delay(redDelay);
if(S1<t || S2<t || S4<t)
{
digitalWrite(signal3[2], LOW);
digitalWrite(signal3[1], HIGH);
delay(yellowDelay);
}
}
void signal4Function()
{
Serial.println("4");
low();
digitalWrite(signal4[0], LOW);
digitalWrite(signal4[2], HIGH);
delay(redDelay);
if(S1<t || S2<t || S3<t)
{
digitalWrite(signal4[2], LOW);
digitalWrite(signal4[1], HIGH);
delay(yellowDelay);
}
}

~ XVIII ~
void low()
{
for(int i=1; i<3; i++)
{
digitalWrite(signal1[i], LOW);
digitalWrite(signal2[i], LOW);
digitalWrite(signal3[i], LOW);
digitalWrite(signal4[i], LOW);
}
for(int i=0; i<1; i++)
{
digitalWrite(signal1[i], HIGH);
digitalWrite(signal2[i], HIGH);
digitalWrite(signal3[i], HIGH);
digitalWrite(signal4[i], HIGH);
}
}

ADVANTAGES

 Avoids wastage of time due to the traffic.


 Fully automatic
 Low power consumption
 It provides the easy access in the traffic light
 Low cost to design the circuit, maintenance of the circuit is good
 By using this Arduino Uno, we can create many more controls to the appliances
 Easy convenience to handle.

~ XIX ~
CONCLUSION

The density-based traffic control system has been designed, constructed and tested to ensure
validation of its function and operations. In this research, we have succeeded in minimizing the
traffic congestions created by the fixed time-based traffic light system. The system is effective and
the cost of production is very low. Future work is recommended in order to produce the device on a
large scale and deploy to all roads in order to reduce traffic congestion in places like Lagos where
traffic congestion has become a big issue.

~ XX ~

You might also like