Timer.h examples don't work

I have copied a couple of example sketches using Timer.h, but get the same result with them all. Her's my very simple code:

#include "Timer.h"

Timer t;
int secCtr;

void setup()
{
Serial.begin(9600);

t.every(1000,updateCount); //update counter every second

}

void loop()
{
t.update();
}

void updateCount()
{
secCtr = secCtr + 1;
Serial.println(secCtr);
}

I copied this from an example on Arduino website and only modified the name of the called function and what happens within the called function, so I can't figure out why it doesn't work.

The error I get is as follows:

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"

D:_Arduino\Misc\Timer__test_2\Timer__test_2.ino: In function 'void setup()':

Timer__test_2:10: error: no matching function for call to 'Timer::every(int, void (&)())'

t.every(1000,updateCount); //update counter every second

^

D:_Arduino\Misc\Timer__test_2\Timer__test_2.ino:10:26: note: candidates are:

In file included from D:_Arduino\Misc\Timer__test_2\Timer__test_2.ino:1:0:

D:\Documents\Arduino\libraries\Timer-2.1/Timer.h:40:10: note: int8_t Timer::every(long unsigned int, void ()(void), void*)

int8_t every(unsigned long period, void (callback)(void), void* context);

^

D:\Documents\Arduino\libraries\Timer-2.1/Timer.h:40:10: note: candidate expects 3 arguments, 2 provided

D:\Documents\Arduino\libraries\Timer-2.1/Timer.h:41:10: note: int8_t Timer::every(long unsigned int, void ()(void), int, void*)

int8_t every(unsigned long period, void (callback)(void), int repeatCount, void* context);

^

D:\Documents\Arduino\libraries\Timer-2.1/Timer.h:41:10: note: candidate expects 4 arguments, 2 provided

exit status 1
no matching function for call to 'Timer::every(int, void (&)())'

Have a look at this and see if it helps any.

You're using an example for an older version (1.x) version of the library but installed the 2.1 version which needs an additional context parameter which will be provided to the callback once it gets called. Don't mix the two versions.

So the examples on the Arduino site are outdated. How useful! :frowning:

Where can I find examples that are compatible with the latest Timer.h OR where can I download the older version of Timer.h, which seems to be superior (or at least easier to use) than the latest version.

Try Google.

Find the site for the latest version of Timer.h - it will almost certainly have usage examples.

The arduino website's playground section is pretty marginal. I don't recommend looking at any part of the official site except store, forum, download and reference for built in functions.

Where can I find examples that are compatible with the latest Timer.h OR where can I download the older version of Timer.h, which seems to be superior (or at least easier to use) than the latest version.

The library itself contains examples of how to use it. If the library is installed on your system you can find the examples in the Examples submenu of the File menu.