Introduction: Traffic Signal Using Arduino and Ultrasonic Sensor
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: https://highvoltages.co/tutorial/arduino-tutorial/traffic-signal-using-arduino-and-ultrasonic-sensor/
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
- ARDUINO UNO BUY IT FROM HERE>>>>>>> https://amzn.to/2QwAqpn
- HC-SR04 BUY IT FROM HERE >>>>>>>>>> https://amzn.to/2LlT91m
- JUMPER WIRES
- GREEN LEDS
- RED LEDS
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.
Question 3 years 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!!
Answer 3 years ago
Try printing the distance values of both sensors and make sure the sensors are working fine and distance are not equal.