The incomplete code is available below. Why is it incomplete? Because the code below only controls the WALK light that comes on when the light is green. YOU have to add in the DON’T WALK signal code. Take a look at the code and the commented section that gives an important clue.
Here’s the INCOMPLETE CODE:
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(9, OUTPUT); //walk signal
pinMode(10,OUTPUT); //don’t walk signal
pinMode(2, INPUT);
}
void loop() {
if(digitalRead(2) == HIGH){
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
digitalWrite(9,LOW);
delay(1000);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
digitalWrite(9,LOW);
delay(3000);
digitalWrite(13,LOW);
digitalWrite(11,HIGH);
digitalWrite(9,HIGH);
} else{
digitalWrite(11, HIGH);
digitalWrite(9, HIGH);
delay(100);
}
}