How to Make Traffic Lights Using Arduino Uno | Make Traffic Control System
Vehicles
moving on-road may cause unpredictable accidents leading to colossal loss of
mass and life. But what is that causing the orderly movement of Vehicles?
Traffic Control System. It is used to avoid accidents and to control the flow
of traffic. In this project, we will be using Arduino Uno to control the
timings of Led in each direction, and with this, we will guide our vehicles to
move towards a particular direction. As we know, in the traffic Control System, the
green led refers to move, Red is to stop, and Orange is to get ready or to slow
down. We have considered Four Directions, When the Green led of Direction 1 is
ON, this indicates that all the vehicles from Direction 2,3, and 4 should move
towards Direction 1. Meanwhile, all the other directions i.e. those in which
orange or green is not turned ON, have their red led turned ON. Afterward,
Orange led of direction 2 turns ON, this indicates that all the vehicles from
direction 1, 3, and 4 should get ready to move towards direction 2. After a
delay (3seconds in this project), the green led turns ON and all the vehicles from
directions 1,3, and 4 move towards direction 2. In a similar way, Orange led of
direction 3 turns ON and then Green led after a delay of 3 seconds. The same happens for direction 4 and in this way, the Orderly movement of vehicles is
ensured.
Required
Components:
To
implement this circuit, you need the following components:
1. Arduino Uno
2. Breadboard
3. Jumper Wires
4. 12 Led (4 Red, 4 Green, 4 Yellow/Orange)
5. 12 Resistors (Any Value between 220-1kΩ)
Circuit
Diagram:
Project
Code:
/* | |
* Written by misbah@deeplift.tech | |
* Watch Complete Project Video at:https://youtu.be/lrFOFhgoa1M | |
* | |
*/ | |
//First of all, we define the pins where we have | |
//connected the LEDs. | |
int red_1=13; | |
int orange_1=12; | |
int green_1=11; | |
int red_2=10; | |
int orange_2=9; | |
int green_2=8; | |
int red_3=7; | |
int orange_3=6; | |
int green_3=5; | |
int red_4=4; | |
int orange_4=3; | |
int green_4=2; | |
void direction_1_green(void) //green LED of direction 1 will turn ON | |
{ | |
digitalWrite(red_1,LOW); | |
digitalWrite(orange_1,LOW); | |
digitalWrite(green_1,HIGH); | |
digitalWrite(red_2,HIGH); | |
digitalWrite(orange_2,LOW); | |
digitalWrite(green_2,LOW); | |
digitalWrite(red_3,HIGH); | |
digitalWrite(orange_3,LOW); | |
digitalWrite(green_3,LOW); | |
digitalWrite(red_4,HIGH); | |
digitalWrite(orange_4,LOW); | |
digitalWrite(green_4,LOW); | |
} | |
void direction_2_orange(void) //orange LED of direction 2 will turn ON | |
{ | |
digitalWrite(red_1,HIGH); | |
digitalWrite(orange_1,LOW); | |
digitalWrite(green_1,LOW); | |
digitalWrite(red_2,LOW); | |
digitalWrite(orange_2,HIGH); | |
digitalWrite(green_2,LOW); | |
digitalWrite(red_3,HIGH); | |
digitalWrite(orange_3,LOW); | |
digitalWrite(green_3,LOW); | |
digitalWrite(red_4,HIGH); | |
digitalWrite(orange_4,LOW); | |
digitalWrite(green_4,LOW); | |
} | |
void direction_2_green(void) //green LED of direction 2 will turn ON | |
{ | |
digitalWrite(red_1,HIGH); | |
digitalWrite(orange_1,LOW); | |
digitalWrite(green_1,LOW); | |
digitalWrite(red_2,LOW); | |
digitalWrite(orange_2,LOW); | |
digitalWrite(green_2,HIGH); | |
digitalWrite(red_3,HIGH); | |
digitalWrite(orange_3,LOW); | |
digitalWrite(green_3,LOW); | |
digitalWrite(red_4,HIGH); | |
digitalWrite(orange_4,LOW); | |
digitalWrite(green_4,LOW); | |
} | |
void direction_3_orange(void) //orange LED of direction 3 will turn ON | |
{ | |
digitalWrite(red_1,HIGH); | |
digitalWrite(orange_1,LOW); | |
digitalWrite(green_1,LOW); | |
digitalWrite(red_2,HIGH); | |
digitalWrite(orange_2,LOW); | |
digitalWrite(green_2,LOW); | |
digitalWrite(red_3,LOW); | |
digitalWrite(orange_3,HIGH); | |
digitalWrite(green_3,LOW); | |
digitalWrite(red_4,HIGH); | |
digitalWrite(orange_4,LOW); | |
digitalWrite(green_4,LOW); | |
} | |
void direction_3_green(void) //green LED of direction 3 will turn ON | |
{ | |
digitalWrite(red_1,HIGH); | |
digitalWrite(orange_1,LOW); | |
digitalWrite(green_1,LOW); | |
digitalWrite(red_2,HIGH); | |
digitalWrite(orange_2,LOW); | |
digitalWrite(green_2,LOW); | |
digitalWrite(red_3,LOW); | |
digitalWrite(orange_3,LOW); | |
digitalWrite(green_3,HIGH); | |
digitalWrite(red_4,HIGH); | |
digitalWrite(orange_4,LOW); | |
digitalWrite(green_4,LOW); | |
} | |
void direction_4_orange(void) //orange LED of direction 4 will turn ON | |
{ | |
digitalWrite(red_1,HIGH); | |
digitalWrite(orange_1,LOW); | |
digitalWrite(green_1,LOW); | |
digitalWrite(red_2,HIGH); | |
digitalWrite(orange_2,LOW); | |
digitalWrite(green_2,LOW); | |
digitalWrite(red_3,HIGH); | |
digitalWrite(orange_3,LOW); | |
digitalWrite(green_3,LOW); | |
digitalWrite(red_4,LOW); | |
digitalWrite(orange_4,HIGH); | |
digitalWrite(green_4,LOW); | |
} | |
void direction_4_green(void) //green LED of direction 4 will turn ON | |
{ | |
digitalWrite(red_1,HIGH); | |
digitalWrite(orange_1,LOW); | |
digitalWrite(green_1,LOW); | |
digitalWrite(red_2,HIGH); | |
digitalWrite(orange_2,LOW); | |
digitalWrite(green_2,LOW); | |
digitalWrite(red_3,HIGH); | |
digitalWrite(orange_3,LOW); | |
digitalWrite(green_3,LOW); | |
digitalWrite(red_4,LOW); | |
digitalWrite(orange_4,LOW); | |
digitalWrite(green_4,HIGH); | |
} | |
void direction_1_orange(void) //orange LED of direction 1 will turn ON | |
{ | |
digitalWrite(red_1,LOW); | |
digitalWrite(orange_1,HIGH); | |
digitalWrite(green_1,LOW); | |
digitalWrite(red_2,HIGH); | |
digitalWrite(orange_2,LOW); | |
digitalWrite(green_2,LOW); | |
digitalWrite(red_3,HIGH); | |
digitalWrite(orange_3,LOW); | |
digitalWrite(green_3,LOW); | |
digitalWrite(red_4,HIGH); | |
digitalWrite(orange_4,LOW); | |
digitalWrite(green_4,LOW); | |
} | |
void setup() | |
{ // Declaring all the LED's as output | |
for(int i=2;i<=13;i++) pinMode(i,OUTPUT); | |
} | |
void loop() //In the loop function, we controlled the signal one | |
// by one to control the flow of traffic. | |
{ | |
direction_1_green(); | |
delay(5000); | |
direction_2_orange(); | |
delay(3000); | |
direction_2_green(); | |
delay(5000); | |
direction_3_orange(); | |
delay(3000); | |
direction_3_green(); | |
delay(5000); | |
direction_4_orange(); | |
delay(3000); | |
direction_4_green(); | |
delay(5000); | |
direction_1_orange(); | |
delay(3000); | |
} |
Hardware
Setup:
For detailed hardware setup, watch our complete project video at YouTube.
EndNote:
Using Arduino Uno, we were able to
control the timings of led and hence successful in guiding the vehicles in
terms of which direction to choose if a particular direction has its green led
ON. We hope that you learned and enjoyed it.
Subscribe Here. Happy Learning!
This comment has been removed by the author.
ReplyDeleteNot only can good lighting prevent theft and accidents, but a proper lighting design can also promote the health and wellbeing of your eyesight. If you enjoy reading or working on your computer, it is very important to make sure that your space is properly illuminated. ProTuningLab
ReplyDeletetf dude
Deleteawesome
ReplyDelete