Traffic Signal Using Arduino and Ultrasonic Sensor



About: I am an electronic engineer and i have been working on embedded system , Iot and Artificial intelligence.

With the era of smart technologies, everything is getting smarter and smart transport system is one of the fields which is going to put a huge impact on our lives.

Arduino being one of the easiest microcontrollers to use, easy to program, easily available in local markets is popular among the students and hobbyists.

Knowing all that, I put my knowledge to make this Density-based traffic signal using Arduino with all the components that are easily available.

This project is a prototype of density based controlling of traffic lights which will check the densities on both ways and will decide which light should be on.

Lets get started.

Step 1: Components

Step 2: Make Connections

we will be using two ultrasonic sensors for two ways and 6 LEDs, 3 for each side.

Ultrasonic Sensor 1:

  • trigger >>>>> Arduino pin D10
  • Echo >>>>>> Arduino pin D9
  • GND >>>>>> GND
  • VCC >>>>>> 5V

Ultrasonic Sensor 2:

  • trigger >>>>> Arduino pin D12
  • Echo >>>>>> Arduino pin D11
  • GND>>>>>>> GND
  • VCC>>>>>>> 5V


  • All the cathodes of the LEDs must go to GND and all of the GND must be common.
  • Red1 Anode>>>>>>Arduino D8
  • Yellow1 Anode>>>>>Arduino D7
  • Green1 Anode>>>>>Arduino D6
  • Green2 Anode>>>>>Arduino D5
  • Yellow2 Anode >>>>Arduino D4
  • Red2 Anode >>>>>Arduino D3

Step 3: Upload Code and You Are Done

You can find the code by clicking here .

Upload code and you are good to go .

Check video if you find any trouble.




    • Arduino Contest 2019

      Arduino Contest 2019
    • Trash to Treasure

      Trash to Treasure
    • Tape Contest

      Tape Contest