Introduction: Smart Traffic Light System
So,Here I am publishing my first ever instructable.It is Quite Exciting I must say.You might be wondering why Traffic Light System...duhh!!Even a rookie could make it.But just wait we have a twist (^_^)...In India we basically have a problem with people here...The PATIENCE problem...i have usually noticed that people usually run out traffic lights there by breaking the rules...although i understand they think that why should we wait even when there's no traffic in other lane?right.So i have built a Smart Traffic Light System which could actually save a lot of accidents and save people from tickets due to over running lights(Traffic Police here is really Strict about this :P).
What this does is it performs the basic functioning of a traffic light.But it keeps on checking for traffic in both the lanes,if a situation arrives that there is no traffic in lane1,the lights for lane 2 do not go red,but stay green and as soon as traffic is sensed on lane 1,light for lane 2 turns back to yellow and then red.
So in this way any of the traffic in lane 1 does not have to wait unnecessarily.
Step 1: Hardware Required
- Arduino Uno R3
- Servo Motor
- Ultrasonic Sensor(HC-SR04)
- Breadboard
- Red,Yellow,Green LEDs (X2)
- Jumper wires: 4 female to male,rest male to male.
Step 2: Connections
Make the Connections as stated Below:
Lane 1:
RED LED==============>7(Digital pin)
YELLOW LED===========>6(Digital pin)
GREEN LED============>5(Digital pin)
Lane 2:
RED LED==============>13(Digital pin)
YELLOW LED===========>12(Digital pin)
GREEN LED============>11(Digital pin)
Servo Motor:
SERVOPIN===========>3
VCC================>5V
GND================>GND
Ultrasonic Sensor:
VCC================>5V
GND================>GND
TRIG PIN============>9(Digital Pin)
ECHO PIN===========>10(Digital Pin)
Step 3: Coding
Download this code mentioned below.
Open the Arduino Software and upload this sketch to your arduino after you have made the connections.
and Tada!!you have your smart traffic light system for two lanes.
TRY IT OUT and do tell me in comments if you have any queries.
Thank you.
Attachments
Step 4: Videos
Sorry for the short videos,but i think you can understand the functionality by this.
the orange cover signifies the traffic.Look for the Lights on Breadboard.

Participated in the
Lights Contest 2017
10 Comments
Question 3 years ago on Introduction
Why is stepper motor used here?
4 years ago
Did u connect any external voltage sources, i can see a black thing in the photo is it a battery ?
Reply 4 years ago
No I didn't connect any external voltage sources. The black box was just to give servo motor a heavy base, so that it doesn't fall back.
Reply 4 years ago
well, i tried to do it
but it have two problems
first the sensor wasn't reading, i tested it alone and it didn't work as well so i will change it and try again
but the other problem is that my servo is not rotating ?
Question 4 years ago on Step 1
Why is the servo motor used?
Answer 4 years ago
Servo Motor is used to rotate the Ultrasonic Sensor to both the sides (left and right).
Please refer to the video.
5 years ago
Can you please help me with the schematics of the board
Reply 4 years ago
I have stated them in the post above.Please refer to that.
6 years ago
Great Arduino system. I am thinking about making a simplified version of this for my son's model car toys.
Reply 6 years ago
Oh Great,best of luck and I believe he's going to love it. :D