int i =0;
const int ledC = 2;
const int ledP = 3;
const int ledO = 4;
const int ledB = 5;
const int ledG = 6;
const int buttonY = 12;
const int buttonR = 13;
int hasilButtonY;
int hasilButtonR;
void setup() {
// put your setup code here, to run once:
pinMode(ledC, OUTPUT);
pinMode(ledP, OUTPUT);
pinMode(ledO, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(ledG, OUTPUT);
pinMode(buttonY, INPUT);
pinMode(buttonR, INPUT);
Serial.begin(9600);
}
void loop() {
hasilButtonY = digitalRead(buttonY);
if(hasilButtonY==1){
i=i+1;
delay(500);
}
hasilButtonR = digitalRead(buttonR);
if (hasilButtonR==1) {
i=i-1;
delay(500);
}
switch (i){
case 1 :
digitalWrite(ledC, HIGH);
digitalWrite(ledP, LOW);
digitalWrite(ledO, LOW);
digitalWrite(ledB, LOW);
digitalWrite(ledG, LOW);
break;
case 2 :
digitalWrite(ledP, HIGH);
digitalWrite(ledC, LOW);
digitalWrite(ledO, LOW);
digitalWrite(ledB, LOW);
digitalWrite(ledG, LOW);
break;
case 3 :
digitalWrite(ledO, HIGH);
digitalWrite(ledC, LOW);
digitalWrite(ledP, LOW);
digitalWrite(ledB, LOW);
digitalWrite(ledG, LOW);
break;
case 4 :
digitalWrite(ledB, HIGH);
digitalWrite(ledC, LOW);
digitalWrite(ledP, LOW);
digitalWrite(ledO, LOW);
digitalWrite(ledG, LOW);
break;
case 5 :
digitalWrite(ledG, HIGH);
digitalWrite(ledC, LOW);
digitalWrite(ledP, LOW);
digitalWrite(ledO, LOW);
digitalWrite(ledB, LOW);
break;
default:
digitalWrite(ledG, LOW);
digitalWrite(ledC, LOW);
digitalWrite(ledP, LOW);
digitalWrite(ledO, LOW);
digitalWrite(ledB, LOW);
break;
}
Serial.println(i);
}