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.

Orignally published at:

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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.


Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    2 Discussions


    Question 6 weeks ago on Step 3

    hey bro i tried the code but its not working ....only the yellow leds are glowing and nothing else is happening!!

    1 answer

    Answer 6 weeks ago

    Try printing the distance values of both sensors and make sure the sensors are working fine and distance are not equal.