Now that your traffic light is working, let’s make the yellow LED blink 3 times before the red light comes on.
To do this, we’ll use a for loop. It allows us to repeat actions in a controlled way.
// Yellow LED blinks three times
for (val = 0; val < 3; val = val + 1) {
digitalWrite(yellowLed, HIGH);
delay(dtYellow);
digitalWrite(yellowLed, LOW);
delay(dtYellow);
}
💡 Try replacing your original yellow LED code with the for loop above.