int led_merah = 23;
int led_kuning = 22;
int led_hijau = 21;
int pushbutton = 5;
int buzzer = 15;
int button_state = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Hello, ESP32!");
  pinMode(led_merah, OUTPUT);
  pinMode(led_kuning, OUTPUT);
  pinMode(led_hijau, OUTPUT);
  pinMode(buzzer, OUTPUT);

  pinMode(pushbutton, INPUT_PULLUP);

  digitalWrite(led_merah, LOW);
  digitalWrite(led_kuning, LOW);
  digitalWrite(led_hijau, LOW);
}

void loop() {
  button_state = digitalRead(pushbutton);

  if (digitalRead(button_state) == LOW){
    digitalWrite(led_merah, HIGH);
    digitalWrite(led_kuning, HIGH);
    delay(1000);
    digitalWrite(led_kuning, LOW);
    delay(1000);
    digitalWrite(led_hijau, LOW);
    
    digitalWrite(buzzer, LOW);

    Serial.println("Dilarang Menyeberang Jalan");
  }
  if (digitalRead(button_state) == HIGH) {
    digitalWrite(led_merah, LOW);
    digitalWrite(led_kuning, LOW);
    digitalWrite(led_hijau, HIGH);
    Serial.println("Silahkan Menyeberang Jalan");
    digitalWrite(buzzer, HIGH);
    delay(4000);
    
    digitalWrite(led_hijau, LOW);
    digitalWrite(buzzer, LOW);
  }
  else{
    
  }

}