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()) {
}
}
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
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.