Hi, In my new project I am developping a laptimer using an LCD 16x2.
I am using a START / STOP and RESET bottom.
But I am finding hard to include a Lap calculator. Any idea please?
Arduino millis() tells milliseconds since startup, always runs.
When timing with millis() we save millis value of events like start and lap times and end times.
Time variables are unsigned, usually type unsigned long.
Because unsigned values are like a round clock it is always true within the range for the variables, even through rollover that:
End (where lap is end of lap) millis minus start millis (could be the previous lap!) equals the difference between, elapsed millis.
The same is true when using micros() to time closer.
iIf you have saved times, subtractions give the differences.
Unsigned long millis is good to almost 50 days difference.
when you press start, store millis() in a variable startMillis.
when you press stop, store millis() in a variable stopMillis.
display the difference between stopMillis and startMillis and you have the passed time.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.