Chronometer/stopwatch library that counts the time passed since started.
Copy the Chrono folder to your Arduino or Wiring libraries folder.
// INCLUDE CHRONO LIBRARY
// Documentation : https://github.com/thomasfredericks/Chrono-Arduino-Wiring/blob/master/README.md
// Download : https://github.com/thomasfredericks/Chrono-Arduino-Wiring/archive/master.zip
#include <Chrono.h>
// Instanciate a Chrono object.
Chrono myChrono;
void setup() {
// Start the chronometer on setup.
myChrono.start();
}
void loop() {
// Check whether the chronometer has reached 1000 time units.
if (myChrono.hasPassed(1000)) {
// Do something here...
// Restart the chronometer.
myChrono.restart();
}
}
// INCLUDE CHRONO LIBRARY : http://github.com/thomasfredericks/Chrono
#include <Chrono.h>
// CREATE A CHRONO INSTANCE :
Chrono myChrono;
elapsed() | unsigned long | Returns the elapsed time |
restart() | void | Starts/restarts the chronometer |
hasPassed( timeout ) | bool | Returns true if the chronometer passed the timeout |
Chrono myChronoMicros(SuperChrono::MICROS);
Chrono myChronoSeconds(SuperChrono::SECONDS);
unsigned long mySpecialTimeFunction();
Chrono myChronoMicros(mySpecialTimeFunction);
restart( offset ) | void | You can alternatively start(restart) the chronometer with a time offset |
stop() | void | Stops/pauses the chronometer |
resume( ) | void | Resumes the chronometer |
hasPassed( timeout,restartIfPassed ) | bool | If the chronometer passed the timeout, returns true and restarts the chronometer |
add( time ) | void | Immediately adds some time to the chronometer |
isRunning( ) | bool | Returns true if the chronometer is currently running |
delay( time ) | void | Waits for some time (in the time unit of the chronometer) |