int led_merah = 23;
int led_kuning = 22;
int led_hijau = 21;
int pushbutton = 2;
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);
}
void loop() {
Serial.println(digitalRead(pushbutton));
while(1){
digitalWrite(led_hijau, LOW);
digitalWrite(led_merah, HIGH);
digitalWrite(led_kuning, HIGH);
delay(1000);
digitalWrite(led_kuning, LOW);
delay(1000);
digitalWrite(buzzer, LOW);
Serial.println("Dilarang Menyeberang Jalan");
if(digitalRead(pushbutton) == HIGH){
break;
}
}
while (1){
digitalWrite(led_merah, LOW);
digitalWrite(led_kuning, LOW);
digitalWrite(led_hijau, HIGH);
digitalWrite(buzzer, HIGH);
delay(4000);
Serial.println("Silahkan Menyeberang Jalan");
break;
}
}