//by may_day112
//menentukan Pin
int red = 11;
int yell = 12;
int gree = 13;
int buttn1 = 2;
int buttn2 = 3;

//membuat state
int buttn1State = LOW;//untuk tombol 1
int buttn2State = LOW;
int ledState = -1;


void setup() {
  pinMode(red, OUTPUT);
  pinMode(yell, OUTPUT);
  pinMode(gree, OUTPUT);
  pinMode(buttn1, INPUT);
  pinMode(buttn2, INPUT);
}

void loop() {
  buttn1State = digitalRead(buttn1);
  buttn2State = digitalRead(buttn2);
  boolean state = false;
  boolean state2 = true;
  if (buttn1State == HIGH || buttn2State == HIGH) {
    state = true;
  }

  while (state) {

    if (state2) {
      digitalWrite(red, LOW);
      digitalWrite(yell, HIGH);
      digitalWrite(gree, LOW);
      state2 = false;
      delay(1000);
    }

    digitalWrite(red, HIGH);
    digitalWrite(yell, LOW);
    digitalWrite(gree, LOW);
    delay(100);
    buttn1State = digitalRead(buttn1);
    buttn2State = digitalRead(buttn2);

    if (buttn2State == HIGH || buttn1State == HIGH) {
      digitalWrite(red, LOW);
      digitalWrite(yell, HIGH);
      digitalWrite(gree, LOW);
      delay(1000);
      state = false;
      break;
    }

  }

  digitalWrite(red, LOW);
  digitalWrite(yell, LOW);
  digitalWrite(gree, HIGH);
}