October 15th, 2015
  • Timer
  • Inline
  • Event driven

Timer library

I've made it my quest to create OOP classes for Arduino. Read about that in this blogpost if you need some more context.

This is a very simple timer class that can help you create timed actions based upon milliseconds. This is not an interrupt timer, so it might not be exactly punctual to the microsecond, but it will do just fine in most cases. The timer can be used in two different ways: as an inline timer or as event timer.

As an inline timer you can simply specify how many milliseconds you want to wait until you want to perform an action. In the loop you check the passed() method. When this is true you simply do whatever you want to do. See the example here.

As an event timer the timer will call a method when the time is passed. You can set the timer as a one-time action, or as a repeating timer. See the example here.

The timer library can be found here on GitHub.
It uses the BaseTimedElement base class which can be found here on GitHub.

< Previous post Overview posts Next post >

Leave a comment

= Thanks for your comment =