int ledBiru = 19;
int ledMerah = 18;
int ledKuning = 5;
int button = 15;
int buttonKlik = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(ledBiru, OUTPUT);
pinMode(ledMerah, OUTPUT);
pinMode(ledKuning, OUTPUT);
pinMode(button, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(button) == HIGH){
buttonKlik++;
delay(200);
lampuNyala(buttonKlik);
delay(200);
}
lampuMati(buttonKlik);
if(buttonKlik >= 3){
buttonKlik = 0;
}
Serial.println(buttonKlik);
delay(10); // this speeds up the simulation
}
void lampuNyala(int count){
if(count == 1){
digitalWrite(ledBiru, HIGH);
}else if(count == 2){
digitalWrite(ledMerah, HIGH);
}else{
digitalWrite(ledKuning, HIGH);
}
}
void lampuMati(int count){
if(count == 1){
digitalWrite(ledBiru, LOW);
}else if(count == 2){
digitalWrite(ledMerah, LOW);
}else{
digitalWrite(ledKuning, LOW);
}
}