Simple Timer repeating function on a input

hi… :slight_smile:
I am doing a project on running a motor for 15 sec with start and stop button and a 15 sec timer (simple timer function).
start button–> start motor, start timer → after 15 sec motor must stop
in case if press stop button motor must stop and timer must reset.
the process repeats…
the problem is the timer runs only once. when i give start button 2nd time the motor did not stop after 15 sec… how can i eleminate my error… need suggestion pls…

sketch_nov27c.ino (643 Bytes)

You use the SimpleTimer library the wrong way. timer.run() must be called in every loop. It does not start the timer but it's responsible to call the callback function if it's time to do so. The function is called repeatedly after the time has passed but there's a restartTimer() method to let start from the beginning again. So the start button should call enable() and restartTimer() while the stop button should call disable().