int Red_LED = 10000;
int Yellow_LED = 2000;
int Green_LED = 15000;

int current_time = 0;
int previous_time = 0;

int count = 0;

void setup() {
 
  pinMode(4, INPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop() {
  
  current_time = millis() - previous_time;

  if (digitalRead(4) == HIGH){
    if (current_time < 5000){
      Green_LED = 20000;
      Red_LED = 5000;
    }
    else if (current_time < Red_LED){
      Green_LED = 20000;
    }
  }
  
  if (count == 0){
    digitalWrite(11, HIGH);
    if (current_time > (Red_LED)){
      digitalWrite(11, LOW);
      count = 1;
    }
  }
  else if (count == 1){
    digitalWrite(9, HIGH);
    if (current_time > (Red_LED + Green_LED)){
      digitalWrite(9, LOW);
      count = 2;
    }
  }
  else if (count == 2){
    digitalWrite(10, HIGH);
    if (current_time >= (Red_LED + Green_LED + Yellow_LED)){
      digitalWrite(10, LOW);
      count = 0;
     previous_time = millis();
      current_time = 0; 

      Green_LED = 15000;
      Red_LED = 10000;
    }
  }


}