Sensors Based Traffic Control System
Sensors Based Traffic Control System
Session 2018-2022
Submitted By
DEPARTMENT OF TECHNOLOGIES,
SARHAD UNIVERSITY OF SCIENCE AND INFORMATION
TECHNOLOGY,
PESHAWAR, PAKISTAN
1
APPROVAL SHEET
The undersigned, appointed by the Dean of Faculty of Engineering and Technology, have
examined the thesis entitled,
Presented by,
The candidates for the degree of Bachelor of Technology (B.sc engineering technology) in
Electrical and hereby certify that, in their opinion, it is worthy of acceptance.
Dr.Wasal Khan
Director, Department of Technologies
2
AUTHOR'S DECLARATION
We hereby declare that we are the sole author of this thesis titled “SENSORS BASED
TRAFFIC CONTROL SYSTEM”. This is a true copy of the thesis, including any required
final revisions, as accepted by our examiners. This thesis is entirely our own work. It is
further declared, that we have fulfilled all the requirements in line with the Quality Assurance
guidelines of the Higher Education Commission.
3
ABSTRACT
In many countries, vehicles driver still be contingent on the traffic police to control the
traffic system according to the thickness of traffic. There has been made a lot of studies on
making the traffic signals high-tech by using image processing techniques, infra-Red Sensor,
and laser sensors. The price and involvement are the biggest challenge in these systems.
So, to evade the before mentioned obstacles and with the paying of Machine-to-Machine
M2M Communication, a system of traffic signalling that is based on ultrasonic sensors,
microcontrollers, drivers and a set of some other hardware has been developed, where only
two ultrasonic sensors are used at each road at 500 meters on the road away from the
traffic light where there's apparent traffic congestion that needs to be resolved. The ultra-sonic
sensors would detect the thickness of traffic and interconnect to Arduino that is in charge for
acquiring signals from sensors on the roads and that Arduino is further connected to led
drivers to change the road lights according to the traffic density. After the collection of data
from all ultrasonic sensors Arduino will calculate the density of traffic on the roads and take
the decision to open the road signal of the road having higher traffic. The road having higher
number of traffic will be preferred to be opened first.
There are two modes in the project one is traditional timing system in which timing for
signals is assigned to every road and which gets operated sequence wise. The other mode is
of sensors based in which ultrasonic sensors are connected to Arduino and serves the system
as discussed above.
Our proposed project there is also a system for ambulance too. As ambulance always needs a
clear path for reaching to hospitals and bring patients in time to save their lives.so in our
system ambulance can green the signal light to clear its path to hospital by means of a rf
remote by pressing a button.
4
Acknowledgements
In the name of Allah, the most Merciful and Beneficent First and Foremost, praise is to
ALLAH, the Almighty, and the greatest of all, on whom ultimately, we depend for
sustenance and guidance. I would like to thank Almighty Allah for giving me the opportunity,
determination and strength to do my research. His continuous grace and mercy with me
throughout my life and ever more during the tenure of my research. Now, I would like to
thank and express my deep and sincere gratitude to my supervisor Engr. Fayaz ahmad,
Department of Technology, Sarhad University of Science and IT Peshawar for his continuous
support, guidance and encouragement. In addition to being an excellent supervisor, he is a
man of principles and has immense knowledge of research in general and his subject in
particular. I appreciate all his contributions of time, support and ideas.
I would like to thank my colleagues and friends for discussions, suggestions and criticism. I
would also like to express my gratitude to my friends back home for supporting and
encouraging me throughout my studies. I enjoyed spending the evening time with them.
Thanks for giving me such a joyful time.
I owe everything to my family who encouraged and helped me at every stage of my personal
and academic life and longed to see this achievement come true. I dedicate this work to my
sincere brother, generous father and my loving mother. Every breath of my life and drop of
blood in my body is dedicated to my family. I love you all.
5
CONTENTS
ABSTRACT .................................................................................................................... 4
ACKNOWLEDGEMENTS............................................................................................... 5
CHAPTER 1 .................................................................................................................... 8
1.1INTRODUCTION................................................................................................. 8
1.2 LITERATURE SURVEY ...................................................................................... 9
1.3 THE PROPOSED SYSTEM .............................................................................. 10
CHAPTER 2.................................................................................................................. 12
2.1 BACKGROUND:................................................................................................ 12
2.2 RED LIGHT....................................................................................................... 13
2.3 YELLOW LIGHT ............................................................................................... 13
2.4 GREEN LIGHT.................................................................................................. 13
CHAPTER 3.................................................................................................................. 14
3.1 SENSORS BASED SYSTEM ............................................................................ 14
3.2 LEFT ROAD ULTRASONIC SENSORS............................................................ 15
3.3 DOWNWARD ROAD ULTRASONIC SENSORS .............................................. 15
3.4 SYSTEM ALGORITHM ..................................................................................... 16
CHAPTER 4.................................................................................................................. 14
4.1. ULTRASONIC SENSOR.................................................................................... 17
4.2 PIN OUT OF ULTRASONIC SENSOR ............................................................. 17
4.3 HC-SR04 SENSOR FEATURES ...................................................................... 18
4.4 HC-SR04 ULTRASONIC SENSOR - WORKING ............................................. 18
4.5 HOW TO USE THE HC-SR04 ULTRASONIC SENSOR.................................. 19
4.6. ARDUINO MICROCONTROLLER .................................................................... 20
4.7 ULN2003A........................................................................................................ 21
4.8 FEATURES....................................................................................................... 22
4.9 APPLICATIONS ............................................................................................... 23
4.10 16X2 LCD......................................................................................................... 23
4.11 4-BIT AND 8-BIT MODE OF LCD: ................................................................... 25
4.12 INTERFACING WITH ARDUINO MEGA IN OUR PROJECT .......................... 25 4.13
5.4. LEDS ........................................................................................................ 26 4.14 RF
MODULE (4 CHANNEL)............................................................................ 27
4.15 FLOW CHART................................................................................................. 29
6
CHAPTER 5.................................................................................................................. 45
5.1 CODING.............................................................................................................. 45
CHAPTER 6.................................................................................................................. 76
EXPERIMENTAL RESULT AND DISCUSSION ........................................................... 79
CONCLUSION AND RECOMMENDATIONS ............................................................... 81
REFRENCES ................................................................................................................ 82
7
CHAPTER 1
1. INTRODUCTION:
Traffic signal transmissions framework was presented which is invented and the name of
this title is “Lester” which is implemented the idea of the traffic light control is the two
names the first which he were mention in his book so far the red and green light in 1912. And
after that in 1920 the “Williams” he invented the idea of red yellow and green signals for a
traffic light control system. And today’s world is used for that idea and after to control the
cars into the road which is helped to controlled the cars by using this large scale controlling
system of car. The traffic light control system is commonly used in our daily life we all knew
that this is necessary for our life because we travel one place into another so we can use the
car for car which is movement on the road so the signal comes to car so we stop our car
immediately for using traffic light signals. Ease, and persevering movement banner structure
that exceptional to enlighten different issues and further develops the action framework.
The entire World is innovatively developing and Pakistan is no exemption from that.
And by utilizing the colossal development in data innovation IT and numerous other
advances, individuals utilized to utilize an agreeable approach to everyday life like brilliant
screens, electrically charged Vehicles, and so on, carriage to the extraordinary case and,
persons branching as opposed to holding up in amassed open transportation. The situation of
movement blockage occurs since vehicles and to driver for perceived to the lessening slow,
large season to excursion for the cars arranging finished large ordinary. Action Signs will
generally control to state action of combinations.
Movement structure at this point is old planned and sometimes actually controlled where
the Activity cop is responsible for getting sorted out the passage of vehicles in view of the
action thickness. This situation is astoundingly problematic since more often than not if cop
eventually control action it can be justification and to movement obstruct in streets. In this
way, to understand these issues, a bundle of asks about has been finished by using
correspondence methodology and information development for getting sorted out organism
movement flagging.
8
2. LITERATURE REVIEW:
In this section we will discuss the previous work here and to know about the idea of Traffic
light control system as well.
1) R. Weil, J. Wootton, 1998, he invents the idea to controlling interface between the other
components like microcontroller and to adjust in traffic light control. In this step basically he
implements the different tools and save multiple car in the memory section. Basically, he
was just implementing that idea into the project shape structure which is he invented on the
project base structure the idea is to define the traffic light control and it is control by the
microcontroller which means that the main work is here to control the signal light from the
microcontroller. On words this system will helpful on the upcoming time and which means
that this idea to for time consuming and effort less because this system is full control on the
microcontroller to control the traffic lights.
2) " K. Thatsanavipas, N. Ponganunchoke, et al ", 2010, [2] presents this paper on travel
framework as indicated by traffic thickness it's based upon the method of picture handling,
for example, edge discovery to recognize the thickness of traffic that outcomes from the ebb
and flow traffic flagging framework. The principal benefit of making a brilliant framework
for traffic controlling is blockage decrease, functional expense, give a substitute street to the
driver, lastly to construct a foundation with High limit. For the most part, its convoluted
framework and furthermore excessively costly because of the utilization of great
photographic activity introducing streets adjacent to figuring assuming that contrasting and
the proposed sensors costs and introducing strategy.
3) Wanjing MA “2008” [3] in this paper the working of the Traffic light control through Infrared
signal or sensor which is work on the Green light by using the microcontroller. Which means
that this idea is for only the green lights he was implemented and the other platforms. All the
information is to control by the main microcontroller and the signal is comes from the car
detected by the sensor like infrared and that signals is executed by the sensors and signal to
the main microcontroller. The car detect through the sonsor so microcontroller change the
color green into the red light. The timing sets into the main microcontroller and give then the
signals to the board or anything which is operated by the sensor.
9
4) Moch Agung Prasetyo, “2018”, [4] he mentioned in his paper for different methodology
about the traffic light control system. It is very common and very important for the
implemented the traffic lights on the street’s road’s and main high way. The sensor is used
for the recognition the cars and speed which this tool used for the methodology and the main
street on the road which he implemented the idea of traffic light control system. This idea is
used for the traffic which is used for the heavy traffic jam.
past writing explored, current frameworks consumes utilized an Ultraviolet (IR) device
or a considerable lot sonography sensors arrangement of circulation regulatory
disadvantage of test. The test in utilizing numerous supersonic devices to distinguish degree
clog on street, gridlock circumstance microcontroller thusly first address light traffic second
addresses typical gridlock third address weighty traffic signals decrease the gridlock (TJ) And
one more test of involving three sonography sensor for every street its price. The test in
utilizing [IR] is that the vehicles should be close to recognizing the presence between the
vehicle isn't generally imaginable this technique might be problematic.
As needs be, planned framework traffic control framework a sensor introduced streets to
detects the vehicles and these sensors are are connected to microcontroller(Arduino) which is
a brain of project and takes all decisions like counting the vehicles on the road,starts and
stops the timer and turning the lights on and off and other functions used.we proposed a smart
project which is a combination of sensors,drivers and leds and some other hardware,which
will work smart As an smart system is needed to control this traffic system we made and
proposed a system consists on sensors and some engineering techniques to make system
smart and intelligent so we tried our best to make a prototype system based on ultrasonic
sensors,Arduino mega 2560,led drivers,and rf module.
As a human is precious and valueable and in now a days due to increase in road traffic
ambulance faces a lot of traffic on its way,so to get ambulance in time and manage a quick
way to reach ambulance to hospital to save human life.for this purpose a special arrangement
for ambulance is needed to bypass the traffic clock based system.we introduced an RF
module which is interfaced with Arduino to bypass the timing based lights and by using this
ambulance paths green light gets on and ambulance gets a clear path to get reach to hospital
to save humans life.
10
Our system will serve both systems the traditional timing based traffic signals
operation and sensors based density following smart system.which will be discussed below.
11
Chapter 2
Background:
12
Every traffic light has its own mean and function. Peoples are educated to learn the mean
of each light in schools and everyday life, so peoples should follow the mean of each light
and make their lives easy and to be a part of the managed system.
Red light
The meaning of each light has a unique approach like in case of red light the traffic of
the particular road should stop and keep their engines off and waits for their turn calmly, by
this way the fuel consumption can also be made good if the engine remains off the petrol
consumption will be less and also the environment will remain less polluted.so the red light
means to stop the vehicles and should wait for green light to be glow on the same leds panel.
Yellow light
Yellow light or amber light means to turn on the engine and wait till the green light
gets glow and to cross if the yellow light is glowing,
Green light
Green light means to go towards the destination and leave the place for others. So, all
these lights are the part of system and has its own story.
13
Chapter 3
Fig no 3
14
S1 to S8 are the ultrasonic sensors at the side of each road to check out the traffic as
shown in fig no 3 these sensors are connected to microcontroller.
15
4. SYSTEM ALGORITHM
1) Vehicles detection through ultrasonic sensors
2) Comparison of all roads traffic
3) Decision making and operation of lights
4) Greenlight for the road with higher traffic and red for rest of the roads
5) Special operation for ambulance route
6) After ambulance operation system will get back to normal routine
7) Two mode system first one is the traditional timing based and second is the smart
sensors based.
16
Chapter 4
17
Pin Pin Name Description
Number
• Exactness: 3mm
Working
This device is used for the detection purpose only. In this module there is 4 pins and ach pin
having different working principle for to used. The first pin used for the Vcc which means
positive 5 volt and second pin is trigger basically the trigger pin is used for the signals
purpose and third pin echo and last pin is ground pin to operate this module is to operate this
device which is 5 volt.
The Ultrasonic spreader communicates a supersonic wave, this wave journeys is talk about to
that is addressed texture back is the wave to operated and give them to the sensors watched
Supersonic beneficiary the device is showed up inside picture.
18
To know about this task is basically the main for the purpose is to operate the device which is
operated by the Arduino and the signals give them to detect the object. The signal of the
module to operate the object from the waves signals and to access the object it can be
automatically operated by the module device.
In this module the pic which we used and to connect to the Arduino is trigger pin. Input and
output pin for connected the pic trigger and echo pic also.
In our project HC SR-04 ultrasonic modules are connected with arduino mega 2560 one of
the ultrasonic module is shown in figure.
19
Eight ultrasonic sensors are interfaced with arduino mega 2560 one is for counting the
entering vehicles and one is for counting the leaving vehicles.So two sensors for each
road.Eight ultrasonic sensors are connected from pin A0 to a13 and 2 and 3no pin of arduino.
20
Figure 5: microcontroller (Arduino Mega)
ULN2003A
The device chip is operated five volts. Features normal flyback, trading burdens. It can come
in PDIP, SOIC, SOP or TSSOP pack are ULN2002A, anticipated dissimilar reasoning info
levels.
Uln 2003a
21
ULN2003 may be a 16 Stick IC, comprising of 7 Darlington sets (each match ensured with
concealment diode) and in this way has the capability to handle a most extreme of 7
loads(could be inductive). In basic words, we have 7 drivers in a single ULN2003 chip and in
this way can control a greatest of 7 loads. Each Darlington match can handle a most extreme
500mA stack, whereas the crest esteem is 600mA. Similarly, the greatest yield voltage of
each Darlington pair is 50V. In the underneath figure, you'll be able see ULN2003 has 16
Pins, where inputs and their individual yields are set before each other(for ease of circuit
designing). Other than I/O Pins, we have Ground Stick where we got to give 0V & Vcc
(Common) pin.
A single Darlington pair comprises of two bipolar transistors its greatest working values are
50V & 500mA (crest 600mA). These two transistors of the Darlington combine have a
common emitter, whereas their collectors are open. Here’s the circuit chart of single
Darlington combine, appeared within the underneath figure:
Features
This chip is called the current limitation and voltage also. The motorists to resembled without
a doubt advanced ebb and flow yield. Without a doubt help, mark best to additional, both
electrically genuinely, has been finished. Basically this addition to operate in the different
interfere to stepper motor, there is motor requires tall assessments can't give to interfere
contraptions. Primary determinations:
22
• 500 mA assessed gatherer current
• 50 V yield
• Incorporates yield
Applications
To operate this chip in a circuit to the transfer the light and to display the LEDs
16x2 LCD
LCD is basically used for the displaying purpose in our project we use the LCD which is
show the values the output and final results to show in the LCD. We use 16x2 display module
and also connected to the micro-controller. Which means that the data will show in LCD.
The above figure is 16x2 lcd’s layout and indicating the connections of each pin.The function
and description and also a pin number is discussed in the below figure for consideration
23
For brief discussion lets turn the back side of lcd for more information the below figure
shows the back side of 16x2 lcd display module.
24
The specific pixel to show up empowered which is given in the below fig.
All the data is show and result will display and final results and all the data is show in the
display LCD. Basically the LCD is used for the displaying purpose and this rushed errand
deal with all by to assistance of MCU, in this way Border IC like HD44780, which remains
equestrian on LCD Unit the situation.
25
Lcd shows the number of vehicles on each road.we can watch all the process of increments
and decrements in the counts of vehicles when vehicles crosses the ultrasonic sensors.
5.4. LEDS
The light emitting diode is a light source that exudes the current and streams. Electrons inside
the semiconductor device which electron dumps, cathartic essentialness inside casing
photons. Shade is light concluded by the essentialness expected for electrons to cross the
band cleft of the semiconductor. White light is gotten various semiconductors layer of light-
discharging phosphor on the semiconductor expedient. LEDs have various focal points over
brilliant light sources, counting lower control use, longer lifetime, advanced actual strength,
more diminutive gauge, and faster trading. In exchange for these generally good
characteristics, obstructions of LEDs consolidate electrical obstacles to moo voltage and
overall to DC (not AC) control, inability to supply steady light from a beating DC or an AC
electrical stock source, and lesser most prominent working temperature and limit
temperature. LEDs, generally speaking, need electronic back parts to work, while a brilliant
26
bulb can and customarily takes care of business directly from an unregulated DC or AC
control source.
In our project red green and yellow leds are used to perform different functions.Red led
means “Stop” .Green led means “Go” and yellow led means “Ready to go”.leds are interfaced
with uln2003.we have used 12 leads for 4 roads so current consumption of leds was high and
arduino cant supply that power to leds.uln2003 is used as leds driver in our project.
RF module (4 channel)
4 channel RF module is used in our project to detect the presence of ambulance. Ambulance
will be having a remote which have 4 buttons each roads green light can be open by these
buttons. Each button is assigned to each green light by means of Arduino. Type of rf module
is shown in fig below
27
A,B,C and D are the buttons of Rf module’s transmitter each of the button is connected to an
ic PT2262 which is used in rf transmitters. Each of button transmits its own bit towards the
receiver’s circuit by means of an antenna. Both of the modules have antenna with the help of
which both circuits are able to do communication with each other.Pt2262 which is a
transmitters ic is impaired with PT2272 which is a receiver’s ic and communicates with the
transmitters ic PT2272 is distinguishes the data transmitted from transmitters ic PT2262
.Diagrams of PT2262 and PT227 are shown below
The above diagram shows the connections of the buttons(switches), supply connections and
components used with PT2262.This diagram describes the whole circuitry of the receiver side
module which is enclosed in remote casing.
PT2272 RECIEVERS IC
PT2272 module is connected to arduino to get inputs from the buttons installed in
transmitters remote and this remote will be operated by ambulances driver.pin outs of
recievers module are as follow
(a) Gnd
(b) +5v
(c) D0
(d) D1
(e) D2
(f) D3
(g) VT
28
The circuit diagram of PT2272 is shown in a fig below in which we can easily study the
supply,connections and components used in the circuitry of receiving module
Diagram of PT2272
FLOW CHART
29
Figure 7: system flowchart
30
CHAPTER 5
#include "LiquidCrystal.h"
LiquidCrystal lcd(12, 11, 10, 7, 6, 9);
long duration1;
int distanceCM1;
long duration2;
int distanceCM2;
31
const int maximumRange3 = 100; // Maximum measured range in CM
long duration3;
int distanceCM3;
long duration4;
int distanceCM4;
long duration5;
int distanceCM5;
32
const int maximumRange6 = 100; // Maximum measured range in CM
long duration6;
int distanceCM6;
long duration7;
int distanceCM7;
long duration8;
int distanceCM8;
int buttonState11 = 0;
int buttonState22 =
0; int buttonState33
= 0; int
buttonState44 = 0;
//int buttonPushCounter1 = 0;
int pc1 = 0; // counter for the number of button presses
int buttonState5 = 0; // current state of the button
int lastButtonState1 = 0;
//int b=pc1++;// previous state of the button
34
//int buttonPushCounter2 = 0;
int pc2 = 0; // counter for the number of button presses
int buttonState2 = 0; // current state of the button
int lastButtonState2 = 0; // previous state of the button
void setup() {
// mySerial.begin(9600);
lcd.begin(16, 2);
//pinMode(micPin, INPUT);
pinMode(micPin, INPUT_PULLUP);
35
Serial.begin (9600);
pinMode (trigpin1, OUTPUT);
// digitalWrite(trigpin,LOW);
pinMode (echopin1, INPUT );
// pinMode (4, OUTPUT);
//digitalWrite(trigpinright,LOW);
pinMode (echopin3, INPUT );
// digitalWrite(trigpin,LOW);
pinMode (echopin5, INPUT );
// pinMode (4, OUTPUT);
pinMode (trigpin6,
OUTPUT);
// digitalWrite(trigpin,LOW);
pinMode (echopin6, INPUT );
// pinMode (4, OUTPUT);
36
pinMode (trigpin7, OUTPUT);
// digitalWrite(trigpin,LOW);
pinMode (echopin7, INPUT );
// pinMode (4, OUTPUT);
pinMode (trigpin8,
OUTPUT);
// digitalWrite(trigpin,LOW);
pinMode (echopin8, INPUT );
// pinMode (4, OUTPUT);
pinMode (14,OUTPUT);
pinMode
(15,OUTPUT);
pinMode (16,OUTPUT);
pinMode
(17,OUTPUT);
pinMode (18,OUTPUT);
pinMode
(19,OUTPUT);
pinMode (20,OUTPUT);
pinMode
(21,OUTPUT);
pinMode (22,OUTPUT);
pinMode
(23,OUTPUT);
pinMode (24,OUTPUT);
pinMode
(25,OUTPUT);
37
pinMode(micPin11, INPUT);
pinMode(micPin22,
// Config();
}
void loop(){
mic();
road1();
road2();
road3();
road4();
compare();
rf();
}
void mic()
{
buttonStat
e6 =
digitalRea
d(micPin);
if (buttonState6 == HIGH)
{
time();
lcd.setCursor(11,0);
lcd.print("t " );
38
}
else if (buttonState6 == LOW)
{
lcd.setCursor(11,0);
lcd.print("s " );
compare();
void road1()
{ digitalWrite(trigpin1,
LOW);
delayMicroseconds(2);
digitalWrite(trigpin1, HIGH);
delayMicroseconds(10);
duration1 = pulseIn
(echopin1, HIGH,
maximumRange1*60);
distanceCM1 = duration1/58.2;
delay (50);
//Serial.println(distanceCM1);
39
if(distanceCM1>= 10 && distanceCM1 <= 13)
{
//buttonPushCounter1+
+; pc1++;
// Serial.println( pc1);
delay(1000);
lcd.setCursor(7,0);
lcd.print("R2:" );
lcd.setCursor(10,0);
int b=(pc1 );
lcd.print(b);
digitalWrite(trigpin2, LOW);
40
delayMicroseconds(2);
digitalWrite(trigpin2, HIGH);
delayMicroseconds(10);
duration2 = pulseIn
(echopin2, HIGH,
maximumRange2*60);
distanceCM2 = duration2/58.2;
delay (50);
//Serial.println(distanceCM2);
//
Serial.print(
"pc1: ");
// Serial.println(pc1);
delay(1000);
lcd.setCursor(7,0);
lcd.print("R2:" );
lcd.setCursor(10,0);
int b=(pc1);
lcd.print(b);
41
}
void road2()
{ digitalWrite(trigpin3,
LOW);
delayMicroseconds(2);
digitalWrite(trigpin3, HIGH);
delayMicroseconds(10);
duration3 = pulseIn
(echopin3, HIGH,
maximumRange3*60);
distanceCM3 = duration3/58.2;
delay (50);
//Serial.println(distanceCM3);
//Serial.print("pc2: ");
// Serial.println(pc2);
delay(1000);
lcd.setCursor(0,0);
42
lcd.print("R1:" );
lcd.setCursor(3,0);
// lcd.setCursor(0,1);
int c=(pc2);
lcd.print(c);
digitalWrite(trigpin4, LOW);
delayMicroseconds(2);
digitalWrite(trigpin4, HIGH);
delayMicroseconds(10);
duration4= pulseIn (echopin4,
HIGH,
maximumRange4*60);
distanceCM4 = duration4/58.2;
delay (50);
Serial.println(distanceCM4);
// if(pc2==-1){
43
// pc2=0;
if(pc2<=0){
pc2=1;
}
//
Serial.print(
"pc2: ");
//
Serial.printl
n(pc2);
delay(1000);
lcd.setCursor(0,0);
lcd.print("R1:" );
lcd.setCursor(3,0);
int c=(pc2);
lcd.print(c);
}
}
void road3()
{ digitalWrite(trigpin5,
LOW);
delayMicroseconds(2);
digitalWrite(trigpin5, HIGH);
delayMicroseconds(10);
duration5 = pulseIn
(echopin5, HIGH,
maximumRange5*60);
distanceCM5 = duration5/58.2;
delay (50);
Serial.println(distanceCM5);
44
if(distanceCM5 >= 10 && distanceCM5 <=13 )
{
pc3++;
Serial.print("pc3: ");
// Serial.println(pc2);
delay(1000);
lcd.setCursor(7,1);
lcd.print("R4:" );
lcd.setCursor(10,1);
int c=(pc3);
lcd.print(c);
digitalWrite(trigpin6, LOW);
delayMicroseconds(2);
digitalWrite(trigpin6, HIGH);
delayMicroseconds(10);
duration6= pulseIn (echopin6,
HIGH,
maximumRange6*60);
distanceCM6 = duration6/58.2;
delay (50);
45
//Serial.println(distanceCM6);
// if(pc3==-1){
//pc3=0;
if(pc3<=0){
pc3=1;
}
//
Serial.print(
"pc3: ");
// Serial.println(pc3);
delay(1000);
lcd.setCursor(7,1);
lcd.print("R4:" );
lcd.setCursor(10,1);
int c=(pc3);
lcd.print(c);
}
void road4()
{ digitalWrite(trigpin7,
LOW);
delayMicroseconds(2);
46
digitalWrite(trigpin7, HIGH);
delayMicroseconds(10);
duration7= pulseIn (echopin7,
HIGH,
maximumRange7*60);
distanceCM7 = duration7/58.2;
delay (50);
//Serial.println(distanceCM7);
// Serial.print("pc4: ");
// Serial.println(pc2);
delay(1000);
lcd.setCursor(0,1);
lcd.print("R3:" );
lcd.setCursor(3,1);
int c=(pc4);
lcd.print(c);
47
digitalWrite(trigpin8, LOW);
delayMicroseconds(2);
digitalWrite(trigpin8, HIGH);
delayMicroseconds(10);
duration8= pulseIn (echopin8,
HIGH,
maximumRange8*60);
distanceCM8 = duration8/58.2;
delay (50);
//Serial.println(distanceCM8);
//if(pc4==-1){
//pc4=0;
if(pc4<=0){
pc4=1;
}
// Serial.print("pc4: ");
Serial.println(pc4);
delay(1000);
lcd.setCursor(0,1);
lcd.print("R3:" );
48
lcd.setCursor(3,1);
//lcd.setCursor(0,1);
int c=(pc4);
lcd.print(c);
}
}
void
compare(){
if( pc1>
pc2 &&
pc3 &&
pc4 ){
lcd.print("c1 " );
digitalWrite(relay1,HIGH); //////////////ALL RED ON////////////////
lcd.setCurs
or(13,0);
digitalWrite(relay2,LOW)
;
digitalWrite(relay3,LOW)
;
digitalWrite(relay3,LOW)
;
digitalWrite(relay4,HIGH)
;
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
//
digitalWrite(relay6,HIGH);
digitalWrite(relay7,HIGH)
;
digitalWrite(relay8,LOW); 49
digitalWrite(relay9,LOW);
digitalWrite(relay10,LOW);
digitalWrite(relay11,LOW);
// digitalWrite(relay12,LOW);
digitalWrite(relay12,HIGH);
lcd.setCursor(13,0);
lcd.print("c2 " );
digitalWrite(relay4,HIGH)
;
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay7,HIGH);
digitalWrite(relay8,LOW);
digitalWrite(relay9,LOW);
digitalWrite(relay10,HIGH);
digitalWrite(relay11,LOW);
digitalWrite(relay12,LOW);
}
50
else if( pc3> pc2 && pc4 && pc1 ){
lcd.setCursor(13,0);
lcd.print("c3 " );
digitalWrite(relay1,HIGH) //////////////ALL RED ON////////////////
;
digitalWrite(relay2,LOW); //////1//////////
digitalWrite(relay3,LOW);
digitalWrite(relay4,HIGH); /////3//////
digitalWrite(relay5,LOW)
;
digitalWrite(relay6,LOW)
;
digitalWrite(relay7,LOW); /////////2//////
digitalWrite(relay8,LOW);
digitalWrite(relay9,HIGH)
;
digitalWrite(relay10,HIGH); ///////4//////////
digitalWrite(relay11,LOW);
digitalWrite(relay12,LOW);
}
lcd.setCursor(13,0);
51
lcd.print("c4 " );
digitalWrite(relay4,LOW);
digitalWrite(relay5,LOW);
digitalWrite(relay6,HIGH)
;
digitalWrite(relay7,HIGH)
;
digitalWrite(relay8,LOW);
digitalWrite(relay9,LOW);
digitalWrite(relay10,HIGH);
digitalWrite(relay11,LOW);
digitalWrite(relay12,LOW);
}
void time()
{
52
digitalWrite(relay1,HIGH); //////////////ALL RED ON////////////////
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay4,HIGH)
;
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay7,HIGH);
digitalWrite(relay8,LOW);
digitalWrite(relay9,LOW);
digitalWrite(relay10,HIGH);
digitalWrite(relay11,LOW);
digitalWrite(relay12,LOW);
delay (3000);
rf();
digitalWrite(relay1,LOW); ///////////// ROAD 1 RED OFF YELLOW
ON///////////
digitalWrite(relay2,HIGH)
; delay (1000);
digitalWrite(relay2,LOW);
digitalWrite(relay3,HIGH)
; delay (3000);
rf();
digitalWrite(relay3,LOW);
digitalWrite(relay1,HIGH)
;
53
digitalWrite(relay4,LOW);
digitalWrite(relay5,HIGH)
; delay (1000);
//rf();
digitalWrite(relay5,LOW);
digitalWrite(relay6,HIGH)
;
delay (3000);
rf();
digitalWrite(r
elay6,LOW);
digitalWrite(relay4,HIGH);
digitalWrite(relay7,LOW);
digitalWrite(relay8,HIGH);
delay (1000);
digitalWrite(relay8,LOW);
digitalWrite(relay9,HIGH);
delay (3000);
rf();
digitalWrite(relay7,HIGH);
digitalWrite(relay9,LOW);
digitalWrite(relay10,LOW);
digitalWrite(relay11,HIGH);
delay (1000);
digitalWrite(relay11,LOW);
digitalWrite(relay12,HIGH);
delay (3000);
54
rf();
//time();
void rf(){
buttonState11 = digitalRead(micPin11);
buttonState22 = digitalRead(micPin22);
buttonState33 =
digitalRead(micPin33); buttonState44
= digitalRead(micPin44);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay4,HIGH)
;
digitalWrite(relay5,LOW);
55
digitalWrite(relay6,LOW);
digitalWrite(relay7,HIGH);
digitalWrite(relay8,LOW);
digitalWrite(relay9,LOW);
digitalWrite(relay10,HIGH);
digitalWrite(relay11,LOW);
digitalWrite(relay12,LOW);
*/
}
else if(buttonState11 == HIGH && buttonState22==LOW && buttonState33==LOW
&& buttonState44==LOW){
digitalWrite(relay2,LOW);
digitalWrite(relay3,HIGH)
;
digitalWrite(relay4,HIGH)
;
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay7,HIGH);
digitalWrite(relay8,LOW);
digitalWrite(relay9,LOW);
digitalWrite(relay10,HIGH);
digitalWrite(relay11,LOW); 56
digitalWrite(relay12,LOW);
Serial.print("A ");
delay(5000);
digitalWrite(relay7,HIGH);
digitalWrite(relay8,LOW);
digitalWrite(relay9,LOW);
digitalWrite(relay10,HIGH);
digitalWrite(relay11,LOW);
digitalWrite(relay12,LOW);
Serial.print("B ");
delay(5000);
57
}
digitalWrite(relay4,HIGH)
;
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay7,LOW);
digitalWrite(relay8,LOW);
digitalWrite(relay9,HIGH)
;
digitalWrite(relay10,HIGH);
digitalWrite(relay11,LOW);
digitalWrite(relay12,LOW);
Serial.print("C ");
delay(5000);
}
else if(buttonState11 == LOW && buttonState22==LOW && buttonState33==LOW
&& buttonState44==HIGH){
58
digitalWrite(relay1,HIGH) //////////////ALL RED ON////////////////
;
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay4,HIGH)
;
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay7,HIGH)
;
digitalWrite(relay8,LOW);
digitalWrite(relay9,LOW);
digitalWrite(relay10,LOW);
digitalWrite(relay11,LOW);
digitalWrite(relay12,HIGH);
Serial.print("D ");
delay(5000);
}
59
CHAPTER 6
Sensors are connected and placed on the the wooden board giving a look like a roads.S1
and S2 are the sensors used for counting the entering and leaving the vehicles for left
road.and a set of leds is used to manage the traffic of left road.
60
S1 is representing the entering Sensor and S2 presents leaving Sensor in the fig above
and a set of leds representing the traffic signals also shown.
61
7. EXPERIMENTAL RESULT AND DISCUSSION
In this point when the future model have occurred executed, a couple of cases that come
about because of relating the planned structure action flagging scheme, the events in view of
this information coming after devices concurrently. A representation is each case it associated
with arduino board to perusing board each case.
Case#1
1) When there is a gridlock in two streets of the crossing point simultaneously together
ultrasonic sensors the two streets drive convey message to the micro-controller open the
green light. the Arduino drive offer need to the street which will have higher traffic on it.if
road1(left street) is higher then the street road2(right street)
Case#2
Road3
>
Road4
Road3 ------>Green light on
Road4------->Red light on
Case#3
62
Road1------>Green light on
Road2------->Red light on
Road3------->Red light on
Road4------->Red light on
Case#4
Road2------>Green light on
Road1------->Red light on
Road3------->Red light on
Road4------->Red light on
Similarly in all cases all the comparison based decisions will be taken from
arduino.
63
8. CONCLUSIONS AND
RECOMMENDATIONS
Exemplary structures of action signals rely essentially upon a movement cop for
coordinating and controlling the action consenting to the thickness of traffic. So much asks
about have been finished to work out or assessing the movement thickness and utilizing a
sensor to control the traffic lights in view of that thickness information besides there's a
couple of action control structure that uses picture planning as a device for computing the
action thickness.
Similarly, with the moving nearer method is Machine to Machine victimization data
advancement, Traffic Signing Framework founded on the ultrasonic sensor is made,
anywhere this device is conveyed one side of street where the traffic stick a overpowering
and should settled.
As this system is changeable so we can easily amend more settings if required for make
it more smart in the coming days this system will rule the traffic and will overcome on traffic
jam.
64
REFERENCES
[1] R. Weil, J. Wootton and A. Garcia Ortiz,” Traffic Incident Detection Sensor and
Algorithms”, “Journal of Mathematical and Computer. Modeling, Vol.27 (9), 1998,
pp.257-291
[2] K. Thatsanavipas, N. Ponganunchoke, et al., “Wireless Traffic Light Controller”
Proceedings of 2nd International Science, Social Science, Engineering and Energy
Conference, Nakhonphanom, Thailand. 2010.
[3] Ashok. P.V, SivaSankari.S Vignesh Mani,” International Journal of Applied
Engineering Research” ISSN 0973-4562 Volume 12, Number 19 (2017)
[4] Hamara Chaudhuri, Nishanth P Raikar,” Traffic Control Management with help of
State of Control Algorithm using Ultrasonic Sensors & GSM Technology”,”
International Research Journal of Engineering and Technology (IRJET)”, Volume:
05 Issue: 04 | Apr-2018
[5] Pampa Sadhukhan, Firoj Gazi,” An IoT based Intelligent Traffic Congestion
Control System for Road Crossings”,” International Conference on Communication,
Computing, and Internet of Things (IC3Io)”, Conference Paper. February 2018.
[6] Moch Agung Prasetyo, Roswan Latuconsina and Tito Waluyo Purboyo,” A
Proposed Design of Traffic Congestion Prediction Using Ultrasonic Sensors”,”
International Journal of Applied Engineering Research ISSN 0973-4562 “, Volume 13,
Number 1 (2018)
[7] Ashish Jain, Manisha Mittal, and Harish Verma, Amrita rai,” Traffic Density
Measurement-based On-road Traffic Control using Ultrasonic Sensors and GSM
Technology”,” Association of Computer Electronics and Electrical Engineers”, 2013
[8] Vahedha, B.Naga Jyothi,” Smart Traffic Control System Using ATMEGA328:
Micro Controller And Arduino Software”,” International Conference on Signal
Processing, Communication, Power and Embedded System (SCOPES)”,2016
[9] Shubham Sahu, Dipanjan Paul, S. Senthilmurugan” density-based traffic signal
control using Arduino Uno”,” International Journal of Novel Research and
Development”,2018
65