const int redPins[] = {27,18,22,13};
const int yellowPins[] = {14,2,17,21};
const int greenPins[] = {25,15,19,4};
void setup() {
for (int i = 0; i < 4; i++) {
pinMode(redPins[i], OUTPUT);
pinMode(yellowPins[i], OUTPUT);
pinMode(greenPins[i], OUTPUT);
}
}
void loop() {
setLights(redPins, HIGH);
delay(2000);
setLights(redPins, LOW);
setLights(yellowPins, HIGH);
delay(1000);
setLights(yellowPins, LOW);
setLights(greenPins, HIGH);
delay(3000);
setLights(greenPins, LOW);
setLights(yellowPins, HIGH);
delay(1000);
setLights(yellowPins, LOW);
delay(1000);
}
void setLights(const int pins[], int state) {
for (int i = 0; i < 4; i++) {
digitalWrite(pins[i], state);
}
}