const int pinButton1 = 4;
const int pinButton2 = 3;
const int pinLED1 = 11;
const int pinLED2 = 10;
const int pinLED3 = 9;
const int pinLED4 = 8;
void setup() {
pinMode(pinButton1, INPUT);
pinMode(pinButton2, INPUT);
pinMode(pinLED1, OUTPUT);
pinMode(pinLED2, OUTPUT);
pinMode(pinLED3, OUTPUT);
pinMode(pinLED4, OUTPUT);
// aktifkan pull-up resistor
digitalWrite(pinButton1, 1);
digitalWrite(pinButton2, 0);
}
void loop() {
if(digitalRead(pinButton1) == 0){
digitalWrite(pinLED1, 1);
digitalWrite(pinLED2, 1);
digitalWrite(pinLED3, 1);
digitalWrite(pinLED4, 1);
delay(200);
digitalWrite(pinLED1, 0);
digitalWrite(pinLED2, 1);
digitalWrite(pinLED3, 1);
digitalWrite(pinLED4, 1);
delay(200);
digitalWrite(pinLED1, 0);
digitalWrite(pinLED2, 0);
digitalWrite(pinLED3, 1);
digitalWrite(pinLED4, 1);
delay(200);
digitalWrite(pinLED1, 0);
digitalWrite(pinLED2, 0);
digitalWrite(pinLED3, 0);
digitalWrite(pinLED4, 1);
delay(200);
digitalWrite(pinLED1, 0);
digitalWrite(pinLED2, 0);
digitalWrite(pinLED3, 0);
digitalWrite(pinLED4, 0);
delay(200);
}else if(digitalRead(pinButton2) == 0){
digitalWrite(pinLED1, 0);
digitalWrite(pinLED2, 0);
digitalWrite(pinLED3, 0);
digitalWrite(pinLED4, 0);
delay(500);
digitalWrite(pinLED1, 1);
digitalWrite(pinLED2, 0);
digitalWrite(pinLED3, 0);
digitalWrite(pinLED4, 0);
delay(500);
digitalWrite(pinLED1, 1);
digitalWrite(pinLED2, 1);
digitalWrite(pinLED3, 0);
digitalWrite(pinLED4, 0);
delay(500);
digitalWrite(pinLED1, 1);
digitalWrite(pinLED2, 1);
digitalWrite(pinLED3, 1);
digitalWrite(pinLED4, 0);
delay(500);
digitalWrite(pinLED1, 1);
digitalWrite(pinLED2, 1);
digitalWrite(pinLED3, 1);
digitalWrite(pinLED4, 1);
delay(500);
}else{
digitalWrite(pinLED1, 1);
digitalWrite(pinLED2, 0);
digitalWrite(pinLED3, 0);
digitalWrite(pinLED4, 0);
delay(100);
digitalWrite(pinLED1, 0);
digitalWrite(pinLED2, 1);
digitalWrite(pinLED3, 0);
digitalWrite(pinLED4, 0);
delay(100);
digitalWrite(pinLED1, 0);
digitalWrite(pinLED2, 0);
digitalWrite(pinLED3, 1);
digitalWrite(pinLED4, 0);
delay(100);
digitalWrite(pinLED1, 0);
digitalWrite(pinLED2, 0);
digitalWrite(pinLED3, 0);
digitalWrite(pinLED4, 1);
delay(100);
}}