i have created a for loop.
But i cannot find how to use the index on variables
Tried several + and other solution but without succes...
what am i doing wrong???
My code is:
// read the pushbutton input pin:
buttonState1 = digitalRead(sensor1);
buttonState2 = digitalRead(sensor2);
buttonState3 = digitalRead(sensor3);
buttonState4 = digitalRead(sensor4);
buttonState5 = digitalRead(sensor5);
buttonState6 = digitalRead(sensor6);
buttonState7 = digitalRead(sensor7);
for (int i=1; i <= 7; i++){
// sensor1
if ((sensor + i) == HIGH ) {
(buttonState + i ) = HIGH;
} else {
buttonStatei = LOW;
}
if (buttonStatei != lastButtonStatei) { // compare the buttonState to its previous state
if (buttonStatei == HIGH) {
// wend from off to on:
client.publish(location,i"/on");
Serial.println(location,i"/on");
} else {
// wend from on to off:
client.publish(location,i"/off");
Serial.println(location,i"/off");
}
delay(wait); // Delay a little bit to avoid bouncing
}
lastButtonStatei = buttonStatei; // save the current state as the last state,
}