// Buatlah Program untuk menyalakan LED protokol terdapat traffic light
#define LED_Hijau 19
#define LED_Merah 18
#define LED_Kuning 5
#define Tombol_Hijau 15
void setup()
{
pinMode(LED_Hijau, OUTPUT);
pinMode(LED_Merah, OUTPUT);
pinMode(LED_Kuning, OUTPUT);
pinMode(Tombol_Hijau,INPUT);
digitalWrite(LED_Hijau, LOW);
digitalWrite(LED_Merah, LOW);
digitalWrite(LED_Kuning, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(15) == HIGH) {
digitalWrite(LED_Kuning,HIGH);delay(3000);
digitalWrite(LED_Merah,HIGH);delay(5000);
digitalWrite(LED_Kuning,HIGH);delay(2000);
digitalWrite(LED_Kuning,LOW);delay(1000);
digitalWrite(LED_Merah,LOW);delay(1000);
digitalWrite(LED_Hijau,HIGH);delay(3000);
digitalWrite(LED_Hijau,LOW);delay(1000);
}
else {
digitalWrite(LED_Hijau,LOW);delay(3000);
digitalWrite(LED_Merah,LOW);delay(3000);
digitalWrite(LED_Kuning,LOW);delay(3000);
}
}