The ArduinoTimer class in our Arduino library is a simple wrapper around the Arduino’s millis() to make it easier to run code periodically.

Using the millis() timer directly, you need to write something like:

Using the ArduinoTimer class you can write:

The methods supported by the ArduinoTimer are:

  • Reset(); Resets the timer to the current value of the millis timer
  • EllapsedMilliseconds(); Returns the number of milliseconds that have passed since the timer was last reset
  • EllapsedSeconds(); Returns the number of seconds that have passed since the timer was last reset
  • TimePassed_Milliseconds(Period, AutoReset — optional); Returns true if Period milliseconds have elapsed since the timer was last reset. If AutoReset is true, or not present, the timer will be reset if the period has passed
  • TimePassed_Seconds(Period, AutoReset — optional); Returns true if Period seconds have elapsed since the timer was last reset. If AutoReset is true, or not present, the timer will be reset if the period has passed
  • TimePassed_Minutes(Period, AutoReset — optional); Returns true if Period minutes have elapsed since the timer was last reset. If AutoReset is true, or not present, the timer will be reset if the period has passed
  • TimePassed_Hours(Period, AutoReset — optional); Returns true if Period hours have elapsed since the timer was last reset. If AutoReset is true, or not present, the timer will be reset if the period has passed
  • StartTime(); The value of the millis counter when the timer was last reset
Recent Posts

Leave a Comment

Start typing and press Enter to search