Does anyone know how to use the millisdelay library

this is the library

does anyone know how to maker a time that resets if something happens so like if an input is pressed it is reset

#include "millisDelay.h" 
millisDelay sadDelay;

// constants won't change. They're used here to set pin numbers:
const int buttonPin1 = 2;  // the number of the pushbutton pin
const int motorPin = 3;    // the number of the vibrating motor pin
const int buttonPin2 = 6;
const int buttonPin3 = 7;

void setup() {


  sadDelay.start(10000);  // start a 10sec delay
}

void loop() {
  // check if delay has timed out
  if (sadDelay.justFinished()) {
  }
 

}
  if(ButtonStatus == pushed) {
    sadDelay.start(10000);  // start or restart a 10sec delay
  }

I know nothing of the library but creating a timer that resets is trivial with the standard millis timer methodology. Just set your startTimer variable to millis if a button is pushed

try

sadDelay.restart();
// another way:
sadDelay.repeat();

See the examples and source code on github.

i was just worried that i would mess up the other millis timers

There is no problem using a library. It is a shortcut and gets you there faster. My own preference is to only use the library as a shortcut once I understand the basic principles. Millis timing is not difficult if you follow the logic and you can do lots of timers easily. It does depend on if you are goal driven or progress driven. With a library you reach your goal fast but doing it yourself you will progress in understanding and coding techniques faster.

Good luck

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.