Search

# Density Based Traffic Signal System using Microcontroller

Nowadays, controlling the traffic becomes major issue because of rapid increase in automobiles and also because of large time delays between traffic lights. So, in order to rectify this problem, we will go for density based traffic lights system. This article explains you how to control the traffic based on density.

In this system, we will use IR sensors to measure the traffic density. We have to arrange one IR sensor for each road; these sensors always sense the traffic on that particular road. All these sensors are interfaced to the microcontroller. Based on these sensors, controller detects the traffic and controls the traffic system.

Outline

## Density Based Traffic Signal System Circuit Principle:

The main heart of this traffic system is microcontroller. IR sensors are connected to the PORT C (PC0, PC1, PC2, and PC3) of the microcontroller and traffic lights are connected to PORT B and PORT D. If there is a traffic on road then that particular sensor output becomes logic 0 otherwise logic 1. By receiving these IR sensor outputs, we have to write the program to control the traffic system.

Also Read the Post – How IR Sensor Based Car Parking Guard Works?

If you receive logic 0 from any of these sensors, we have to give the green signal to that particular path and give red signal to all other paths. Here continuously we have to monitor the IR sensors to check for the traffic.

## Density Based Traffic Signal System Circuit Diagram:

### Circuit Components:

• ATmega8 controller
• PCB board
• IR sensors -4
• LED’s-12(4-red,4-green,4-yellow)
• Serial cable
• Connecting wires

### Density Based Traffic Light Control System Circuit Design:

This circuit consists of 4 IR sensors, atmega8 microcontroller, 4 traffic lights.

IR transmitter looks like an LED. This IR transmitter always emits IR rays from it. The operating voltage of this IR transmitter is 2 to 3v. These IR (infra red) rays are invisible to the human eye. But we can view these IR rays through camera.

IR receiver receives IR rays that are transmitted by IR transmitter. Normally IR receiver has high resistance in order of mega ohms, when it is receiving IR rays the resistance is very low. The operating voltage of IR receiver also 2 to 3V.

We have to place these IR pair in such a way that when we place an obstacle in front of this IR pair, IR receiver should be able to receive the IR rays. When we give the power, the transmitted IR rays hit the object and reflect back to the IR receiver.

Instead of traffic lights, you can use LEDs (RED, GREEN, YELLOW). In normal traffic system, you have to glow the LEDs on time basis. If the traffic density is high on any particular path, then glows green LED of that particular path and glows the red LEDs for remaining paths.

In normal traffic system, we allow the traffic for a time delay of 1 minute for each path.

The above figure shows the IR sensor circuit. Here 330 ohm resistor is used to drop the voltage otherwise IR transmitter may get damaged. To vary the obstacle sensing distance, we have used a potentiometer. We have taken the ouput from transistor collector. This sensor gives the digital output.

### How to Operate Density based Traffic Signal System Circuit?

• Connect 12V battery or adaptor to the development board.
• Switch on the supply.
• Burn the program to the ATmega8 microcontroller by keeping the programming switch sw2 in program mode.
• Connect four IR sensors to PORT C.
• Connect LEDs to PORT B and PORT D.
• Arrange all this LED’s same as like traffic lights.
• Arrange one IR sensor for each road.
• Now you can see the normal traffic system based on time basis.
• Now if you place any obstacle in front of any IR sensor, then the system allows the traffic of that particular path by glowing GREEN light.
• Finally, turn off the board power supply.

### Limitations of this Circuit:

• 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.

### 115 Responses

1. RENUKA B. KHATKE says:

What will be the range of IR sensors.

Here, the range of IR sensors is 10cm and it is a prototype circuit. In real time, we use different sensors for traffic signal system.

1. sravan says:

i want to do this project so now i need internal circuit so please provide me madam

Sir,
please told me the IC program language

2. Anub dey says:

It is a prototype circuit so we use IR sensors which range is 10cm.But in real time which sensor is used.what is the program and how I got the program of microcontroller on density base traffic control.

1. Kanian says:

In real time applications you can use IR detectors, which has a range of about 100m

3. Sanket Joshi says:

Is this project completely based on Electronic components?

4. Alden says:

can i know the block diagram of this system?

5. narinder kumar says:

does this ckt diagram works if i want use two IR sensors at each path of traffic light system and if not works them what modifications needed to do so .
if u know that kind circiut then send it to me please .

6. sanjiya says:

good

1. Thank you so much for your comment, we love your support, keep following us at facebook.com/electronicshub.org.

7. jayesh sonawane says:

If we want to connect 8051 in this circuit … it is possible or not ?
if it is possible then what changes should be done in circuit diagram ?

8. chaitanya says:

Send me abstract n cost for the following project:
Density Based Traffic Signal System using Microcontroller

We are not selling any projects, we love to educate students through this blog.

Thank you.

1. bangash says:

Dear sir, what will happen if the traffic is high from all the ends, i mean if IR sensor detect traffic from the four side or more then one side at the same time.

Thanks

2. sidra shakoor says:

‘I want to make it for semester final project and i want to make it as same as it is.

9. jayesh sonawane says:

in this project we can use micro controller 8051 or not ? if the answer is yes then what could be circuit diagram ?

10. Saishyam says:

Im going to do project on title “Density based traffic light control”
My questions are as follows
1. What type of sensor can be used for density based traffic signal control project?
2.If the density on all roads are same means what will happen?
3.If there is a political procession and thousands of people gathered in a road means how IR sensor differentiate vehicle from people? Also in case of above situation will IR sensor detect that crowd as density ?
4. please send me program of microcontroller for this project..
Thankyou.

11. pcmodi says:

12. Ammar says:

I would like to get your guys’ code. I have been making the same thing for my class’s final project using an arduino board with an atmega controller but I can’t get the case and break statements right. It would be helpful if I could have a look at your code to debug mine.
Much appreciated.

plz send me code of this project

14. Ameenpal Kaur Malhans says:

I am doing same project using ARM Processor that is FRDMKL25z , I want to know about coding in that.

15. sidra shakoor says:

i need coding for my final semester project n i will make it as same as it is plz i need coding …

16. sidra shakoor says:

i have to make it as final project plz give me coding..

1. sidra shakoor says:

i need to knw that how can i produce hex file.. plz help or email me the hex file plzzzz…

2. sidra shakoor says:

plz email me hex file plz

1. shubhanP says:

use keil uvision to convert

1. Arindam says:

But in kiel the Atmega8 is not present
So what to do….??
Can any1 tell me what to do…..
Need help

17. grAy-hAt says:

Sir for this c programming code which compiler we have to use is turbo c is gud for it

18. sidra shakoor says:

plz give me the full video i m nt able to do it by myself …

19. Devaraj says:

i want to this project

20. Kiran says:

Hi, I am a student and I would like to know the programming done for this.

21. ramyamurali says:

I am going to implement the exact project as you did….. So pls help me with the exact code and circuit diagram of this project….. Reply me quickly.

22. Anusha says:

1. s.rakesh says:

i had checked it it contains errors

I need the source code for my final project in college.

My project is a smart traffic light system for emergency and VIP vehicle. the traffic light system will communicate with the vehicle to detect the position and movement. When the vehicle at the exact certain position the traffic light will turn green immediately.

please send me the source code, i really need it.

24. AMAL says:

we are going to implement similar kind of project with some modification and we need this project code to view some examples code. we are trying to implement priority based system to this project.

25. kewat says:

I’m 3rd E&TC student .I try to make mini project on traffic signal ie why i want to code

26. Ayush Jain says:

I want the codes and proper circuit diagram for my college project for my internals, so please help me by providing them.

27. Bhavik says:

Can u tell me the exact microcontroller name..
N plz provide the code too.
Mail me

28. Hemalatha. A.M says:

We are going to implemente this project …so kindly send the code….

29. anchu .c.v says:

we are going to implement this project. so please send the code for us as early as possible.

30. mukesh says:

our mini project group want to make the same project,,
and yes we are very interested to make it
so please give us the code……………………..

31. ranjeet says:

I want to make similar project …plzzz send the codes and ckt diagram

32. saravana says:

hy I need to do this same project in my final year so plz provide me a code

33. Jafarbest says:

Yes I want to do the same project on this topic

34. Sandhiya says:

Sir my question is that if particular road contains any ambulance how come we will allow based on density

35. starlin jiji says:

sir, please send me code for density based traffic signal system using microcontroller

36. banu priya says:

i am very interest to do this project so kindly give the code and circuit diagram for this project

1. Anusha says:

We have included both in the article.Please go through it once

37. srihari says:

pls tell us the program used in microcontoller used in this circuit

1. Anusha says:

38. Victor says:

Yes, i need to do the same project in this my final year. I am really interested. Thank you

39. vikash says:

which software did u use to execute this code… and how did u dumped it into atmega8 ic?

1. Anusha says:

Youc can use Avr studio IDE for writing the code..and for burning the code into microcontroller ,you can use PROGISP

40. S Rambabu says:

Thanks for sharing a good project..I am doing this project as any innovative embedded system design as mini project…..But i want to use fuzzy logic and different sensors…..So please help me out..and send me the code also once i will go through that…
Thanking you..

1. Anusha says:

1. Swetha says:

can we go for some other sensor rather than IR

1. Anusha says:

yess you can any other sensor.

41. KAVIBHARATHI.G says:

I want to do this project in first year I can do it this project

42. can i get the code for this project

43. Savitri Balundagi says:

If one side high traffic is there then how will communicate all sensors each other ????Have u developed SPI protocol??and In this why we need external interrupts???

Please go through the code for all the details..

44. zankhit says:

but which loader used in this experiment ??? can we use 8051 loader used in this experiment????

45. kunal says:

2. yes, we want to change and make it different.
3. we want to add emergency way for ambulance.

46. Neha Nagapurkar says:

hi.. we are making our mini project on density based traffic light control with little modifications. we are going to use different sensor like microwave sensor. we want your project code to study about this project.

1. titli says:

what are the components used to make this ciruit…

47. p.charan siddartha reddy says:

how can we find which side has the high density and compare with the other sides at traffic junction.
can we use raspberry pi for density based traffic controller interfacing with IOT.

give the reply for this questions

48. In the circuit diagram,analog IR sensors are used.But in project output video digital sensors are used..So please suggest me to use either analog or digital.And if I use analog sensors,shall i feel any difficulty while implementing this porject?

49. In the circuit diagram,analog sensors are used..But in project output video digital sensors are used.Plz suggest me to use which type of sensors for it

50. Ayush kumar says:

on which software have u compiled the code?

51. Siddharth says:

1) What is the ampere reading of the 12V battery used in this project?

2) what board have you used for the MC?

52. Ashwin Vinu says:

while compiling the code using KEIL software, what extension is to be given to the file, so as to add files to the source group and build target? .C and .ASM extensions are generating various syntax errors.
Do let me know at the earliest.

53. ankit says:

How IR sensor measure density is high on one side?

54. Akshay B says:

when there is traffic on two or more sides how will the signals react?

Can we add the condition that if there is a traffic at only one side then only open the signal for long time,

and when we have traffic at one side and we open the signal for long time what happen when other side also getting traffic? can we abbreviate the delay of signal in this case?

55. shubhanP says:

how is it possible to have a yellow signal for such a long time. and when you kept your hands near sensor it shows red but when it will be turning to green again??? how this can be applied on practical base….Should have to put the car near the sensor.

56. Nikhil says:

What will be the extra components required?
For the example the resistors connected to the LEDs as shown in the output video.
And what will be their value?

57. Siddiq Ghouri says:

Hello, I downloaded the code which is provided and used it. Burnt the hex file onto the Atmega8 mc, but the system is not working as shown in the video. Infact it’s not behaving as a traffic control system at all. Can u pls verify the code and let me know regarding the same ASAP. Also if there are any resistors or as such to be added in the circuit which are not shown in the circuit diagram

Sir can you please provide project report of this project

59. Dhaval says:

every thing is ready but when ir detect the signal then no change in traffic light??

60. Dhaval says:

IR detect the signal but lights are not change..why??

61. titli says:

i am doing the same project as my final year project..i would like to know the components used to make this circuit work..because ours is not..

62. titli says:

i am making the same project as my final year project..so i would like to know the components used to make this project work…

63. Shivani says:

Need all the header files to make this project using AT89S52 microcontroller.

64. kishore kumqr s says:

Administrator…what happens when the traffic on all four sides is high?..how it will detect them?..could u plzz clear up my doubt ..plz…tqq

65. Nachiket Kamod says:

What if there is traffic on two roads how will the signal react?

66. vidya says:

can we count the number of vehicles exactly using IR sensor

67. Akash says:

the picture does not show properly like how the power supply is connected and as the microcontroller is being used how does it work. the one in video seems like Arduino is being used so it is very simple.

68. ANKESH RASTOGI says:

Please tell me more about microcontroller..please provied complete detail about the microcontroller ..and full name of microcontroller used in this project…ATmega 8 please full name after 8 ..which we use in this project.

69. Akshay says:

What is software development tool used for atmega8 coding ?
is given project code is direct hex code or we have to generate it ?
and how to generate ?

70. Ankur says:

sir what value resistor is to be taken for the led

71. pallavi says:

I done this project with 8051 there are some disadvantages if both sides the emergency vehicles come means what will happen?

72. Kashif Mughal says:

hi i want to make project of density based traffic lights system, can u tell me plz which things are required in what ranges also its code.

Instead of ATmega8 can we use pic microcontroller..

1. Anusha says:

yess you can..

1. Arindam says:

Will the code remain same ..???

74. Ganesh says:

F_cpu redefined error is showing

75. Jerry says:

i connect all the leds as same and the sensors and also input the program but the leds are not ON after giving the power supply. what is the problem ???????

what will be the resistor for each LED????

what will be the exact voltage for this???

76. Seema says:

How IR sensor will sense the traffic please explain me coding of sensing

77. renuka says:

LOVE this article (and your others!). It’s actually a great and helpful piece of information. Very nice description regarding traffic signal system using microcontroller. I got clear idea regarding this topic

78. Sunil says:

Sir , please tell me how the IR sensors detect the traffic means to say the on what basis either number of vehicles or any other process. And what is the name of IR sensor which you have used

79. Rosan Saha says:

i Want to do this project using Atmega 16 .. Can anyone provide me the code ???

80. Ram Gopal says:

I want do this project using 8051 microcontroller,so then crystal oscillator should be connected to which pin of the microcontroller.If possible can i have circuit diagram

1. Ravi says:

Crystal Oscillator (usually, 11.0592MHz) must be connected at pins 18 and 19 of 8051.

81. Sharmila says:

Sir, please let me know Is there any difference between wireless technology based traffic signal control and density based traffic control system

82. Swapna says:

What will be the range of resistors for each led?

83. Akash Saraf says:

Will i have to write a seperate code for normal functioning of the traffic lights or the code provided from your side is upto mark?

84. Shivani says:

I am getting undefined identifier at PORTD which is after else statement. How to rectify this error? Please answer

85. Karishma says:

I want code for this project.anybody help me

86. Kautuk Bauva says:

Can I get the code for the prototyping Model? I liked the idea, I’m wanting to take this up as my project topic.

87. spandana chereddy says:

I want to buy that kit so can u send me details of the kit like cost and equipment