Hi, I have a program that includes a stopwatch and a timer. The stopwatch uses millis() to count, which makes it counting the exact time. But for the timer I can't think of a way to use millis(), so I have used a lot's of if's instead of millis(), but I can't get it counting in proper speed, I have tried calibrating it but it's hard and I can't use delays in the rest of the code.
So is there a way to program a timer using millis()?
Delta_G
in your code is it somehow possible to reset your Counter after it is finished ?
is there a way to program a timer using millis()?
Please explain what you mean by "a timer" and what starts it
PALAVRAS:
Delta_G
in your code is it somehow possible to reset your Counter after it is finished ?
At any time you can set 'countDown' to a new value and set 'lastTick' to millis() to start a new countdown.
You will probably want to do something to stop the counter when it hits zero. Right now it goes into negative seconds. That is as easy as changing:
countDown--;
to
if (countDown > 0)
countDown--;