CSE 318 Report
CSE 318 Report
ON
Submitted By
Submitted To
Abstract
The aim of this project is to study and analyse the counting and controlling traffic system by using
8051 controller.
In this system IR sensors are used to measure the density of the vehicles which are fixed within a
fixed distance. All the sensors are interfaced with the microcontroller which in turn controls the traffic
signal system according to density detected by the sensors.
If the traffic density is high on particular side more priority is given for that side. The sensors
continuously keep sensing density on all sides and the green signal is given to the side on priority basis,
where the sensors detect high density. The side with next priority level follows the first priority level.
By using this system traffic can be cleared without irregularities and time delays even though there is
no traffic on the other side can be avoided.
ii
Table of contents
Abstract i
Table of Contents ii
List of Figures iii
List of Tables iv
1. Introduction
1.1. Overview 1
1.2. Project Objectives 1
1.3. Purpose 1
1.4. Scope 1
2. Background Theory
2.1. Block Diagram of Proposed Design 3
2.2. Arduino MEGA 3
2.3. Solution Details 5
3. Hardware Description
3.1. IR Module
3.2. LM358
4. Methodology
4.1. Interfacing IR Module with Arduino
5. Parts List with Cost Estimation
6. Limitations
7. Conclusion
8. Future Scope
References
Appendix
iii
List of Figures
Figure Figure Name Page no.
No.
1.1.1 Block Diagram of proposed design 3
List of Tables
CHATER 1
Introduction
1.1 . Overview
The overview of this project is to implement Density based traffic controlling system using IR
technology and 89S52 controller. 89S52 is very efficient architecture which can be used for low end security
systems and IR is widely adapted technology for communication.
1.2 . Obejctive
The main objective of this project is to control the traffic lights based on the density of the vehicles.
1.3 . Purpose
Purpose of the current work is to study and analyse the counting and controlling system by using 8051
controller.
1.4 . Scope
Current work focuses on how to use effectively IR and 8051 controllers for digital security systems.
2
CHAPTER 2
Background Theory
IR Module-E
IR Module-W
Arduino MEGA
IR Module-N
IR Module-S
2.2.1. Introduction
The Arduino Mega is a microcontroller board based on the ATmega1280. It has 54 digital
input/output pins (of which 14 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 is compatible with most shields
designed for the Arduino Duemilanove or Diecimila.
3
2.2.2. Power
The Arduino Mega can be powered via the USB connection or with an external power supply.
The power source is selected automatically. External (non-USB) power can come either from an AC-to-DC
adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm centre-positive plug into
the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER
connector. The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V,
however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V,
the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.
Each of the 54 digital pins on the Mega can be used as an input or output, using pinMode(),
digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a
maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. The
serial pin is used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the
corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.
2.2.4. Communication
The Arduino Mega has a number of facilities for communicating with a computer, another Arduino,
or other microcontrollers. The ATmega1280 provides four hardware UARTs for TTL (5V) serial
communication. An FTDI FT232RL on the board channels one of these over USB and the FTDI drivers
4
(included with the Arduino software) provide a virtual com port to software on the computer. The Arduino
software includes a serial monitor which allows simple textual data to be sent to and from the Arduino
board. The RX and TX LEDs on the board will flash when data is being transmitted via the FTDI chip and
USB connection to the computer (but not for serial communication on pins 0 and 1).
Rather then requiring a physical press of the reset button before an upload, the Arduino Mega is
designed in a way that allows it to be reset by software running on a connected computer. One of the
hardware flow control lines (DTR) of the FT232RL is connected to the reset line of the ATmega1280 via a
100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the
chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload
button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the
lowering of DTR can be well-coordinated with the start of the upload.
Control electronics
i. Arduino MEGA as the controller for its processing power and large developer community.
ii. IR module is connected to the Arduino MEGA
iii. Traffic lights are interfaced with Arduino MEGA.
CHAPTER 3
Hardware Description
The project is designed to develop a density based dynamic traffic signal system having remote
override facilities. During normal time the signal timing changes automatically on sensing the traffic density
at the junction but in the event of any emergency vehicle like ambulance, fire brigade etc requiring
priority are built in with RF remote control to override the set timing by providing instantaneous green
signal in the desired direction while blocking the other lanes by red signal for some time.
Traffic congestion is a severe problem in many major cities across the world thus it is felt imperative
to provide such facilities to important vehicles.
Conventional traffic light system is based on fixed time concept allotted to each side of the junction
which cannot be varied as per varying traffic density. Junction timings allotted are fixed. Sometimes higher
traffic density at one side of the junction demands longer green time as compared to standard allotted time.
The proposed system using a microcontroller of 8051 family duly interfaced with sensors, changes
the junction timing automatically to accommodate movement of vehicles smoothly avoiding unnecessary
waiting time at the junction.
The sensors used in this project are IR and photodiodes are in line of sight configuration across the
loads to detect the density at the traffic signal. The density of the vehicles is measured in three zones i.e.,
low, medium, high based on which timings are allotted accordingly. The override feature is activated by an
on board RF transmitter operated from the emergency vehicle.
Further the project can be enhanced by synchronizing all the traffic junctions in the city by
establishing a network among them. The network can be wired or wireless. This synchronization will greatly
help in reducing traffic congestion.
6
Fig 3.1:
3.1. IR Module
An infrared sensor is an electronic device, that emits in order to sense some aspects of the surroundings. An
IR sensor can measure the heat of an object as well as detects the motion. These types of sensors measures
only infrared radiation, rather than emitting it that is called as a passive IR sensor. Usually in the infrared
spectrum, all the objects radiate some form of thermal radiations. These types of radiations are invisible to
our eyes, that can be detected by an infrared sensor. The emitter is simply an IR LED (Light Emitting Diode)
and the detector is simply an IR photodiode which is sensitive to IR light of the same wavelength as that
emitted by the IR LED. When IR light falls on the photodiode, The resistances and these output voltages,
change in proportion to the magnitude of the IR light received.
An infrared sensor circuit is one of the basic and popular sensor module in an electronic device. This sensor
is analogous to human’s visionary senses, which can be used to detect obstacles and it is one of the common
applications in real time. This circuit comprises of the following components
LM358 IC
2 IR transmitter and receiver pair
Resistors of the range of kilo ohms.
Variable resistors.
LED (Light Emitting Diode).
3.2. LM348IC
The LM358 IC is a great, low power and easy to use dual channel op-amp IC. It is designed and introduced
by national semiconductor. It consists of two internally frequency compensated, high gain, independent op-
amps. This IC is designed for specially to operate from a single power supply over a wide range of voltages.
The LM358 IC is available in a chip sized package and applications of this op amp include conventional op-
amp circuits, DC gain blocks and transducer amplifiers. LM358 IC is a good, standard operational amplifier
and it is suitable for your needs. It can handle 3-32V DC supply & source up to 20mA per channel. This op-
amp is apt, if you want to operate two separate op-amps for a single power supply. It’s available in an 8-pin
DIP package.
CHAPTER 4
Methodology
4.1.1. Introduction
Arduino interfacing with IR sensor is very simple like interfacing of Switch with the arduino, The obstacle
sensor gives logic 0 as output when there is no obstacle in front of it, and when obstacle is placed in front of
it, it will give logic high output i.e. +5V. We need to read these logic changes on the arduino. Using
digitalRead Command. We can use any IO line as per we requirement.
power source
Total 1872/=
CHAPTER 6
Limitations
IR sensors sometimes may absorb normal light also. As a result, traffic system works in improper way.
IR sensors work only for fewer distances.
We have to arrange IR sensors in accurate manner otherwise they may not detect the traffic density.
CHAPTER 7
Conclusion
In this project, we have implemented density based traffic signal system using Arduino MEGA. The
hardware equipments is tested and result is obtained. This project is cost effective. Implementation of this
project in present day will effectively solve the traffic congestion which is a severe problem in many modern
cities all over the world. Consider a scenario of highly congested where many vehicle such as personal
transport, public transport and emergency vehicle ( Ambulance, Fire brigade , VIP cars etc..) have to wait for
long for the change of traffic signal at intersection points. This leads to the wastage of precious time
especially in case of rescue vehicles for emergency conditions. It is possible to propose dynamic time-based
co ordination schemes where the green signal time of the traffic lights is assigned based on the present
condition of traffic. This is achieved by using IR sensor across the road to monitor the length of vehicle
blocking the road traffic. The signals from the IR receivers are fed to the microcontroller to follow the
program with the time as desired. With a slight modification this project can be implemented in a nearby
area.
CHAPTER 8
Future Scope
As the system takes care of few of the drawbacks of the existing system, there is scope for
further improvement and expansion of this work. The system can be expanded with smart
traffic light control and congestion avoidance system during emergencies emergency cars
such as fire engins and ambulances and have priority over other traffic. This system gives
highest priority to emergency vehicles to pass them. A development of an intelligent traffic
signal control(ITSC) system needed because present traffic light controllers are based on old
microcontroller such as AT89C51 which has very less internal memory and no in-built ADC.
In this project in future we can add module for sensing whose range is more than IR module.
We will modify our coding for controlling the traffic signal according to density.
References
1. http://www.ti.com/product/lm358
2. Manoj Kanta Mainali & Shingo Mabu(2010) “Evolutionary Approach for the Traffic Volume
Estimation of Road Section”,pp100-105,IEEE
3. Shipa S. Chavan, Dr. R.S Deshpande & J.G. Rana (2009),”Design of Intelligent Traffic Light
Controller Using Embedded System” Second international Conference on Emerging Trends in
Enginnerng & Technology, pp1086-1091
Appendix
Complete code for the home automation project
///--------------DECLARING SENSORS--------
int Sensor1=A1;
int Sensor2=A2;
int Sensor3=A3;
int Sensor4=A4;
int Sensor5=A5;
int Sensor6=A6;
int Sensor7=A7;
int Sensor8=A8;
//-----------------VARIABLES--------------------------
int limit=550;
int lowlimit=50;
//------------------OUTPUT LED'S------------------------------------
int ledGreen1=2;
int ledyellow1=3;
int ledRed1=4;
int ledGreen2=5;
int ledyellow2=6;
int ledRed2=7;
int ledGreen3=8;
int ledyellow3=9;
int ledRed3=10;
int ledGreen4=11;
int ledyellow4=12;
int ledRed4=13;
void setup() {
Serial.begin(9600);
pinMode(Sensor1,INPUT);
pinMode(Sensor2,INPUT);
pinMode(Sensor3,INPUT);
pinMode(Sensor4,INPUT);
pinMode(Sensor5,INPUT);
pinMode(Sensor6,INPUT);
pinMode(Sensor7,INPUT);
pinMode(Sensor8,INPUT);
pinMode(ledGreen1,OUTPUT);
pinMode(ledGreen2,OUTPUT);
pinMode(ledGreen3,OUTPUT);
pinMode(ledGreen4,OUTPUT);
pinMode(ledRed1,OUTPUT);
pinMode(ledRed2,OUTPUT);
pinMode(ledRed3,OUTPUT);
pinMode(ledRed4,OUTPUT);
pinMode(ledyellow1,OUTPUT);
pinMode(ledyellow2,OUTPUT);
pinMode(ledyellow3,OUTPUT);
pinMode(ledyellow4,OUTPUT);
digitalWrite(ledRed1,LOW);
digitalWrite(ledRed2,LOW);
digitalWrite(ledRed3,LOW);
digitalWrite(ledRed4,LOW);
digitalWrite(ledGreen1,LOW);
digitalWrite(ledGreen2,LOW);
digitalWrite(ledGreen3,LOW);
digitalWrite(ledGreen4,LOW);
digitalWrite(ledyellow1,LOW);
digitalWrite(ledyellow2,LOW);
digitalWrite(ledyellow3,LOW);
digitalWrite(ledyellow4,LOW);
void loop() {
Serial.print("Sensor1= ");
Serial.println(value1);
Serial.print("Sensor2= ");
Serial.println(value2);
Serial.print("Sensor3= ");
Serial.println(value3);
Serial.print("Sensor4= ");
Serial.println(value4);
Serial.print("Sensor5= ");
Serial.println(value5);
Serial.print("Sensor6= ");
Serial.println(value6);
Serial.print("Sensor7= ");
Serial.println(value7);
Serial.print("Sensor8= ");
Serial.println(value8);
delay(20);
if(value8>limit){
digitalWrite(ledRed4,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledyellow4,HIGH);
delay(500);
digitalWrite(ledGreen4,HIGH);
digitalWrite(ledyellow4,LOW);
delay(5000);
digitalWrite(ledGreen4,LOW);
digitalWrite(ledRed4,HIGH);
}else{
digitalWrite(ledRed4,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledyellow4,HIGH);
delay(500);
digitalWrite(ledGreen4,HIGH);
digitalWrite(ledyellow4,LOW);
delay(2000);
digitalWrite(ledGreen4,LOW);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledRed1,LOW);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow1,HIGH);
delay(500);
digitalWrite(ledGreen1,HIGH);
digitalWrite(ledyellow1,LOW);
delay(15000);
digitalWrite(ledGreen1,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed1,LOW);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow1,HIGH);
delay(500);
digitalWrite(ledGreen1,HIGH);
digitalWrite(ledyellow1,LOW);
delay(10000);
digitalWrite(ledGreen1,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed1,LOW);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow1,HIGH);
delay(500);
digitalWrite(ledGreen1,HIGH);
digitalWrite(ledyellow1,LOW);
delay(5000);
digitalWrite(ledGreen1,LOW);
digitalWrite(ledRed1,HIGH);
}else{
digitalWrite(ledRed1,LOW);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow1,HIGH);
delay(500);
digitalWrite(ledGreen1,HIGH);
digitalWrite(ledyellow1,LOW);
delay(2000);
digitalWrite(ledGreen1,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed2,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow2,HIGH);
delay(500);
digitalWrite(ledGreen2,HIGH);
digitalWrite(ledyellow2,LOW);
delay(10000);
digitalWrite(ledGreen2,LOW);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed2,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow2,HIGH);
delay(500);
digitalWrite(ledGreen2,HIGH);
digitalWrite(ledyellow2,LOW);
delay(5000);
digitalWrite(ledGreen2,LOW);
digitalWrite(ledRed2,HIGH);
}else{
digitalWrite(ledRed2,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed3,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow2,HIGH);
delay(500);
digitalWrite(ledGreen2,HIGH);
digitalWrite(ledyellow2,LOW);
delay(2000);
digitalWrite(ledGreen2,LOW);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed3,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow3,HIGH);
delay(500);
digitalWrite(ledGreen3,HIGH);
digitalWrite(ledyellow3,LOW);
delay(10000);
digitalWrite(ledGreen3,LOW);
digitalWrite(ledRed3,HIGH);
}else if(value6>limit && value7<limit){
digitalWrite(ledRed3,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow3,HIGH);
delay(500);
digitalWrite(ledGreen3,HIGH);
digitalWrite(ledyellow3,LOW);
delay(5000);
digitalWrite(ledGreen3,LOW);
digitalWrite(ledRed3,HIGH);
}else{
digitalWrite(ledRed3,LOW);
digitalWrite(ledRed1,HIGH);
digitalWrite(ledRed2,HIGH);
digitalWrite(ledRed4,HIGH);
digitalWrite(ledyellow3,HIGH);
delay(500);
digitalWrite(ledGreen3,HIGH);
digitalWrite(ledyellow3,LOW);
delay(2000);
digitalWrite(ledGreen3,LOW);
digitalWrite(ledRed3,HIGH);
delay(200);