Traffic Signal Control using Arduino
Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share a Traffic Signal Control using Arduino. Few days earlier, I have posted the same tutorial but it was Traffic Light Signal Using 555 Timer in Proteus ISIS and today we will do the same thing but using Arduino programming. Its quite a simple but good starting project on Arduino. So, if you are new to Arduino then must give it a try.
Traffic Signal Control is quite a usual thing. We see traffic signals daily on our roads and usually engineers are asked to design such projects in their initial semesters. If we look at the traffic signals then we can see they are simply turning ON and OFF lights at some fixed regular intervals. and the pattern is quite simple as well. so I have simply followed that pattern and design the code. You should also have a look at Arduino 3 Phase Inverter. So let's start with designing this project named as Traffic Signal Control using Arduino.
Traffic Signal Control using Arduino
- First of all, design a circuit in Proteus for Traffic Signal Control using Arduino as shown in the below figure:
- Its quite a simple project so the circuit is quite simple as well. You can see I have just placed an Arduino board and plugged three LEDs with it and obviously they are Green, Yellow and Red in color.
- These LEDs are attached to pins 2,3 and 4 of Arduino UNO.
- Now next step is to write the Arduino Code for Traffic Signal Control using Arduino, so I have written and it is shown below:
#define GreenLed 4
#define YellowLed 3
#define RedLed 2
void setup()
{
pinMode(GreenLed, OUTPUT);
pinMode(YellowLed, OUTPUT);
pinMode(RedLed, OUTPUT);
}
void loop()
{
digitalWrite(GreenLed, HIGH);
digitalWrite(YellowLed, LOW);
digitalWrite(RedLed, LOW);
delay(5000);delay(5000);
digitalWrite(GreenLed, LOW);
digitalWrite(YellowLed, LOW);
digitalWrite(RedLed, HIGH);
delay(5000);delay(5000);
digitalWrite(GreenLed, LOW);
digitalWrite(YellowLed, HIGH);
digitalWrite(RedLed, LOW);
delay(3000);
}
- That's the complete code for this project Traffic Signal Control using Arduino and I think its quite self explanatory plus I have also changed the color accordingly.
- First of all Green LED is ON and the rest are OFF which is shown in green color.
- Next Red LED is ON and the rest are OFF after around 10 seconds which you can change by changing these delays.
- Finally the Yellow LED will be ON and you can see it goes OFF just after 3 sec because it has short delay, you can change these delays quite easily.
- Below is the flow chart of above programming for Traffic Signal Control using Arduino which will clear the theme properly.
- Now compile your Arduino code and get the hex file.
Note:
- Now when you upload the hex file into your Arduino, it will give output as shown below:
- So that's how it will work, I hope you got this clearly as its quite simple, will meet you soon in the next tutorial. Till then take care!!! :)