//nama:Muhammad Haris Maksum
//Kelas:XRPL
//Absen:19
int tombol = 2;
int led_hijau = 3;
int led_kuning = 4;
int led_merah = 5;
int jumlahTekanan;
void setup() {
// put your setup code here, to run once:
pinMode(tombol, INPUT);
pinMode(led_hijau, OUTPUT);
pinMode(led_kuning, OUTPUT);
pinMode(led_merah, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int statusTombol = digitalRead(tombol);
if(statusTombol==HIGH){
jumlahTekanan ++;
delay(200);
if(jumlahTekanan==1){
digitalWrite(led_hijau, HIGH);
}
else if(jumlahTekanan==2){
digitalWrite(led_hijau, LOW);
digitalWrite(led_kuning, HIGH);
}
else if(jumlahTekanan==3){
digitalWrite(led_kuning, LOW);
digitalWrite(led_merah, HIGH);
}
else if(jumlahTekanan==4){
digitalWrite(led_kuning, HIGH);
digitalWrite(led_merah, LOW);
}
else if(jumlahTekanan==5){
digitalWrite(led_kuning, LOW);
digitalWrite(led_hijau, HIGH);
}
else if(jumlahTekanan==6){
digitalWrite(led_hijau, LOW);
jumlahTekanan=0;
}
}
}