CIRCUIT:
(4 Way Traffic Light Controller)
(4 Way Traffic Light Controller)
Circuit is pretty simple, so I won't be posting a picture of the schematic. Still if you are having any trouble see the pictures of the original circuit below:
(1) The North - South LEDs are the same, so they will be connected together and then the output would go to the assign pins (See the code, to know which pins I used to the LEDs).
- The Red led to Pin 2
- The Yellow led to Pin 3
- The Green led to Pin 4
(2) Same goes for the East - West LEDs.
- The Red led to Pin 6
- The Yellow led to Pin 7
- The Green led to Pin 8
(3) Make sure to use resistor with every single LED to prevent it from any high current damage.
(4) I included the switch to turn ON and OFF the traffic lights (This step is optional).
CODE:
// 4 Way Traffic Light Controller
// Programmed by, Umar Rao
// For Circuit Schematic go to http://arduinocoder.blogspot.com
int redNS = 2;
int yellowNS = 3;
int greenNS = 4;
int redEW = 6;
int yellowEW = 7;
int greenEW = 8;
void setup() {
pinMode (redNS, OUTPUT);
pinMode (yellowNS, OUTPUT);
pinMode (greenNS, OUTPUT);
pinMode (redEW, OUTPUT);
pinMode (yellowEW, OUTPUT);
pinMode (greenEW, OUTPUT);
}
void loop() {
digitalWrite(redNS, HIGH);
digitalWrite(greenEW, HIGH);
delay(8000);
digitalWrite(redNS, LOW);
digitalWrite(greenEW, LOW);
digitalWrite(greenNS, HIGH);
digitalWrite(yellowEW, HIGH);
delay(1000);
digitalWrite(yellowEW, LOW);
digitalWrite(redEW, HIGH);
delay(7000);
digitalWrite(greenNS, LOW);
digitalWrite(yellowNS, HIGH);
delay(1000);
digitalWrite(yellowNS, LOW);
digitalWrite(redEW, LOW);
}
Circuit is pretty simple, so I won't to posting a picture of the schematic. Still if you are having any trouble see the pictures of the original circuit. Unites States city distances
ReplyDeleteCan you please upload the schematic
DeleteThere is problem
ReplyDeletewhen I verify it says" it is corrected "
but after that I uploaded it in my ardouion UNO it says " error "
Does it tell what kind of error? Because, the code runs perfectly on my arduino.
DeleteHow can you do this with 1 breadboard?
ReplyDeleteThis is great. gonna make some changes to give those poor drivers a chance to slow down haha. Any ideas on how to add in a police stop button mechanic or pedestrian walk system. Im trying to stop traffic NS or EW depending on button press for a few seconds.
ReplyDelete