[SOLVED] Alternatives to delay() - SimpleTimer isn't enough

I think you need to have a play iwth SimpleTimer untill you realised it actually a very AdvancedTimer (see what I did there?)

You only need to set up a pumpOn() function with a timer. Very easy to do.

void pumpOn(){
  // do you pump on functions here
}

Then you can just call timer.setTimeout(1000, pumpOn); when ever you need to turn the pump on 1sec later.

Want to turn it off after XX seconds? Easy:

void pumpOn(){
  // do you pump on functions here
 timer.setTimeout(3600, pumpOff); // turn off after 1min
}

void pumpOff(){
  // do you pump off functions here
}

And if you’re a bit OCD about keeping things tidy then just add this function and call doPump() where ever you like.

void doPump(){
  timer.setTimeout(1000, pumpOn);
}
1 Like