Introduction
In this article, we are going to build little components with LED's called a Smart Traffic Light System
Required Components:
- Arduino Uno
- Led-3
- Bread Board
- Push Button
- Some Wires
Connections:
- Connect LED anode pin to the Arduino digital pin 10,11,12.
- And Cathode pin to the Gnd.
- Push button to the digital pin 7.
Program
- int one = 10;
- int two = 11;
- int three = 12;
- int btn = 7;
- int state = 0;
- void setup()
- {
- pinMode(one, OUTPUT);
- pinMode(two, OUTPUT);
- pinMode(three, OUTPUT);
- }
- void loop()
- {
- if (digitalRead(btn))
- {
- if (state == 0)
- {
- setLights(HIGH, LOW, LOW);
- state = 1;
- } else if (state == 1)
- {
- setLights(HIGH, HIGH, LOW);
- state = 2;
- } else if (state == 2)
- {
- setLights(LOW, LOW, HIGH);
- state = 3;
- } else if (state == 3)
- {
- setLights(LOW, HIGH, LOW);
- state = 0;
- }
- delay(1000);
- }
- }
- void Traffic(int red, int yellow, int green)
- {
- digitalWrite(one, red);
- digitalWrite(two, yellow);
- digitalWrite(three, green);
- }


Delpin Susai RajPosted Aug 28, 2016, 4:42 AM
Nice article
Kumaresh RajalingamPosted Feb 13, 2016, 3:12 AM
Thank you santhakumar sir
Santhakumar MunuswamyPosted Feb 13, 2016, 2:59 AM
Thanks for nice share
Kumaresh RajalingamPosted Feb 13, 2016, 12:31 AM
Thanks Pramod Sir
Kumaresh RajalingamPosted Feb 13, 2016, 12:31 AM
Thanks gowtham Sir
Kumaresh RajalingamPosted Feb 13, 2016, 12:31 AM
Thanks Raja sir
Pramod ThakurPosted Feb 13, 2016, 12:29 AM
Nice..
Gowtham KPosted Feb 12, 2016, 10:57 AM
Good One
Raja TPosted Feb 12, 2016, 5:36 AM
Nice, Thanks for sharing
Kumaresh RajalingamPosted Feb 12, 2016, 2:09 AM
Thank you sibeesh bro
Kumaresh RajalingamPosted Feb 12, 2016, 2:08 AM
Thank you Amit sir
Kumaresh RajalingamPosted Feb 12, 2016, 2:08 AM
Thank you shubham sir
Sibeesh VenuPosted Feb 12, 2016, 12:35 AM
Nice Share
Amit Kumar SinghPosted Feb 12, 2016, 12:32 AM
Nice one
Shubham KumarPosted Feb 12, 2016, 12:31 AM
nice one +1
Kumaresh RajalingamPosted Feb 11, 2016, 8:35 PM
Thanks Jaco
Kumaresh RajalingamPosted Feb 11, 2016, 8:35 PM
Thanks Kartiga
Sr KarthigaPosted Feb 11, 2016, 7:26 PM
Good one sir
Jaco ZwartsPosted Feb 11, 2016, 12:11 PM
Nice share