int red_pin = 13;
int ylw_pin = 9;
int grn_pin = 6;
unsigned long st; // started time for system
unsigned long ct; // current_time
bool red_state;
bool ylw_state;
bool grn_state;
void setup() {
pinMode(red_pin, OUTPUT);
pinMode(ylw_pin, OUTPUT);
pinMode(grn_pin, OUTPUT);
}
void loop() {
ct = millis();
if (ct - st > 15000) {
st = ct;
}
if (ct - st < 7000) {
red_state = HIGH;
}
else {
red_state = LOW;
}
if ((ct-st>5000 && ct-st<7000) || (ct-st>13000)) {
ylw_state = HIGH;
}
else {
ylw_state = LOW;
}
// write the code here for the green
digitalWrite(red_pin, red_state);
digitalWrite(ylw_pin, ylw_state);
digitalWrite(grn_pin, grn_state);
}