setInterval starting a function(withvariable)

Hi,

Is there a way to start a - void function1(int i) - in a setInterval ?
I already tryied this way but i keep on getting errors. (too many arguments in setInterval):
timerNo = timer.setInterval(1000L, function1(myvariable));

I need it to be able to start a relay whose pin is saved in a array in the:

void function1(int i) {
   digitalWrite(relay[i], HIGH);
}

this would avoid me needing to do 10 functions for 10 multiple relays.

Thanks for helping me :slight_smile:

timerNo = timer.setInterval(1000L, function1,10); // repeat 10 times every 1 sec

void function1() {
i++;
digitalWrite(relay[i], HIGH);
if (i>10){
i=0; // rest count
  }
}
1 Like

Thanks !

1 Like