//Soal nomor 22
//Traffic light with Push Button
//Ardiansyah, S.Kom 
//No Peserta 152309267101-14
//Kelas IoT3-3 


int button =7;
int ledHijau = 8;
int ledKuning = 9;
int ledMerah = 10;
void setup() {
  Serial.begin(9600);
  pinMode(button, INPUT);
  pinMode(ledHijau, OUTPUT);
  pinMode(ledKuning, OUTPUT);
  pinMode(ledMerah, OUTPUT);

  digitalWrite(ledHijau, LOW);
  digitalWrite(ledKuning, LOW);
  digitalWrite(ledMerah, LOW);
}
void loop() {
  boolean x = digitalRead(button);

  if (x == true){
    Serial.println("Tombol ditekan");
    digitalWrite(ledKuning, HIGH);
    delay(3000);
    digitalWrite(ledKuning, LOW);
    digitalWrite(ledMerah, HIGH);
    delay(5000);
    digitalWrite(ledKuning, HIGH);
    delay(2000);
    digitalWrite(ledMerah, LOW);
    digitalWrite(ledKuning, LOW);
    digitalWrite(ledHijau, HIGH);
    delay(3000);
    digitalWrite(ledMerah, LOW);
    digitalWrite(ledKuning, LOW);
    digitalWrite(ledHijau, LOW);
  }
  else{
    Serial.println("Tombol belum ditekan");
  }
}