const int led[]={2,3,4,5,6,7,8,9,10,11,12,13}; //nomor pin board
const int pbutton = A5;
const int elektroda[]={1,5,9,12}; //indeks dimulai dari 1 bukan nol
int lightOn = 0;
int pushed = 0;
void setup() {
Serial.begin(9600);
// definisi mode tiap pin:
for(int i=0; i<12; i++){
pinMode(led[i], OUTPUT);
// Serial.println(led[i]);
}
pinMode(pbutton, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
int val = digitalRead(pbutton);
if(val == 1 && lightOn == 0){
pushed = 1-pushed;
delay(100);
}
lightOn = val;
// Serial.println(pushed);
if(pushed == 1){
for(int i=0; i<12; i++){
digitalWrite(led[i], LOW);
Serial.println("Light OFF");
}
}else{
for (int i=0; i<4; i++){
digitalWrite(led[elektroda[i]-1], HIGH);
Serial.println("Light ON");
}
}
}