Density Based Traffic Light Controller Using Arduino: Inter Department Project Report On
Density Based Traffic Light Controller Using Arduino: Inter Department Project Report On
By
Kshitij Chanikya
191FA4595 191FA05181
~I~
VIGNAN’S FOUNDATION FOR SCIENCE TECHNOLOGY AND RESEARCH
Deemed to be UNIVERSITY
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.
~ 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
~ 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
~ 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.
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
~ 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
~ 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 ~