Close this search box.


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.

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:

Density Based Traffic Lights System Circuit Diagram
Density Based Traffic Lights System Circuit Diagram

Circuit Components:

  • ATmega8 controller
  • PCB board
  • IR sensors -4
  • LED’s-12(4-red,4-green,4-yellow)
  • 12v Battery or adaptor
  • 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.

[Also Read: How To Make an Adjustable Timer ]

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.

IR Sensor Circuit
IR Sensor Circuit

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.

Density based Traffic Signal System Circuit Simulation Video:


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.

Density based Traffic Signal System Project Output Video:

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

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

  3. 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 ?

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


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

  5. 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..
    please if anyone knows answer for those questions, please do reply…
    I want to complete this project within a weak..So please help me..

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

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

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

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

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

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

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

  12. 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……………………..

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

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

  14. 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???

  15. 1. we want your project code to study about this project.
    2. yes, we want to change and make it different.
    3. we want to add emergency way for ambulance.

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

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

  18. 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?

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

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

    2) what board have you used for the MC?

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

  22. 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?

    Please reply ASAP

    Thnks in advance!

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

  24. 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?

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

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

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

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

  29. Hi. I am doing this project, i needed your on connections of this circuit. please help
    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.

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

  31. 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 ?

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

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

  34. 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???

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

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

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

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

  39. 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?

Leave a Reply

Your email address will not be published. Required fields are marked *