Timer.h library error.

I am using the Timer.h Library from JChristensen (Arduino Playground - Timer Library)

when I use the oscillate function like below:

t.oscillate(LEDPIN, 500, HIGH);

I see the LED is on all the time. I was expecting the LED to blink every 500 ms. What am I doing wrong.

Also when I use after function:

t.after(12000, stopMotorMotion);

I get some compile error as below:

Arduino: 1.8.9 Hourly Build 2019/03/18 11:12 (Mac OS X), Board: "Arduino/Genuino Uno"

/Arduino/codebase/stepperMotor/stepperMotor.ino: In function 'void setup()':
stepperMotor:20:33: error: no matching function for call to 'Timer::after(int, void (&)())'
   t.after(12000, stopMotorMotion);
                                 ^
In file included from Arduino/codebase/stepperMotor/stepperMotor.ino:2:0:
/Arduino/libraries/Timer-2.1/Timer.h:42:10: note: candidate: int8_t Timer::after(long unsigned int, void (*)(void*), void*)
   int8_t after(unsigned long duration, void (*callback)(void*), void* context);
          ^
/Arduino/libraries/Timer-2.1/Timer.h:42:10: note:   candidate expects 3 arguments, 2 provided
exit status 1
no matching function for call to 'Timer::after(int, void (&)())'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

What am I doing wrong.

Not posting your whole program.

Are you calling t.update() in loop() ?

Yes, I had added t.update. Here is full code.

#include <Stepper.h>
#include <Timer.h>
#define STEPS 2038 // the number of steps in one revolution of your motor (28BYJ-48)
#define MAX_SPEED 16 // can't go faster than this. Keep within range
#define LEDPIN 13 // to show action

Timer t;
Stepper stepper(STEPS, 9, 11, 10 ,12);
int timestamp = 0;
long eventTimer = 10000; // Run for duration in ms.
int stepDir = STEPS;

void setup() {
  // nothing to do
  Serial.begin(9600);
  pinMode(LEDPIN, OUTPUT);
  timestamp = millis();
  t.oscillate(13, 10000, HIGH);
  t.after(eventTimer, reverseMotorDirection);
}

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

void reverseMotorDirection(){
  if(stepDir == STEPS) {
      stepDir = -STEPS;
   } else {
      stepDir = STEPS;
  }
}

void setMotorInMotion() {
  stepper.setSpeed(MAX_SPEED);
  stepper.step(stepDir); 
  Serial.println("Motor is running...");
}

void stopMotorMotion() {
  stepper.setSpeed(0);
  stepper.step(0); 
  Serial.println("Motor Stopped");
}

You should declare timestamp as unsigned long, but it doesn't matter because you dont use it for now.
I believe the call to setMotorInMotion(); should be at the end of the setup, otherwise the motor won't stop after 10 seconds.
Since you defined LEDPIN, use it here:
t.oscillate(LEDPIN, 10000ul, HIGH);Did you try to reduce the value 10000? Use unsigned long values such as 10000ul. The same for eventimer:

const unsigned long eventTimer = 10000ul; // Run for duration in ms

I think this

  if(stepDir == STEPS) {
      stepDir = -STEPS;
   } else {
      stepDir = STEPS;
  }

can be written shorter as

stepDIR = ((stepDir != STEPS) * 2 - 1) * STEPS;

Thanks you @lesept.

But I am still getting issue with the after function, which I have mentioned in my post above.

I am not sure, there seems to be some compile error.

One more question, what I'd like to do is blink the LED irrespective of the loop, with oscillate I see that the LED is blinking according to the motor movement as it runs with the loop, which is right.

But as I said what if I have to blink the LED every 500 ms, I tried using every function in Timer library, that too is giving below error:

unsigned long period = 200;

void setup() {
  // nothing to do
  Serial.begin(9600);
  pinMode(LEDPIN, OUTPUT);
  t.every(period, flashLED, 100);
}

Error I get:

/Users/udhadv/Documents/Arduino/codebase/stepperMotor/stepperMotor.ino: In function 'void setup()':
/Users/udhadv/Documents/Arduino/codebase/stepperMotor/stepperMotor.ino:20:32: warning: invalid conversion from 'void (*)()' to 'void (*)(void*)' [-fpermissive]
   t.every(period, flashLED, 100);
                                ^
In file included from /Users/udhadv/Documents/Arduino/codebase/stepperMotor/stepperMotor.ino:2:0:
/Users/udhadv/Documents/Arduino/libraries/Timer-2.1/Timer.h:40:10: note:   initializing argument 2 of 'int8_t Timer::every(long unsigned int, void (*)(void*), void*)'
   int8_t every(unsigned long period, void (*callback)(void*), void* context);
          ^
/Users/udhadv/Documents/Arduino/codebase/stepperMotor/stepperMotor.ino:20:32: warning: invalid conversion from 'int' to 'void*' [-fpermissive]
   t.every(period, flashLED, 100);
                                ^
In file included from /Users/udhadv/Documents/Arduino/codebase/stepperMotor/stepperMotor.ino:2:0:
/Users/udhadv/Documents/Arduino/libraries/Timer-2.1/Timer.h:40:10: note:   initializing argument 3 of 'int8_t Timer::every(long unsigned int, void (*)(void*), void*)'
   int8_t every(unsigned long period, void (*callback)(void*), void* context);

Maybe you have an older version of the library installed. Check if you have the last one.

Otherwise you can try another library that does similar things.

But as I said what if I have to blink the LED every 500 ms, I tried using every function in Timer library, that too is giving below error:

The signature of the callback function you are trying to use does NOT match the signature that the function MUST have.

Either post ALL of your code, or fix your problem yourself.

Examples are provided here

int afterEvent = t.after(10000, doAfter);

...

void doAfter()
{
Serial.println("stop the led event");
t.stop(ledEvent);
t.oscillate(13, 500, HIGH, 5);
}

and

int every(long period, callback)
Run the 'callback' every 'period' milliseconds.
Returns the ID of the timer event.

int every(long period, callback, int repeatCount)
Run the 'callback' every 'period' milliseconds for a total of 'repeatCount' times.
Returns the ID of the timer event.

int after(long duration, callback)
Run the 'callback' once after 'period' milliseconds.
Returns the ID of the timer event.

int oscillate(int pin, long period, int startingValue)
Toggle the state of the digital output 'pin' every 'period' milliseconds. The pin's starting value is specified in 'startingValue', which should be HIGH or LOW.
Returns the ID of the timer event.

int oscillate(int pin, long period, int startingValue, int repeatCount)
Toggle the state of the digital output 'pin' every 'period' milliseconds 'repeatCount' times. The pin's starting value is specified in 'startingValue', which should be HIGH or LOW.
Returns the ID of the timer event.

@PaulS : what do you mean :

The signature of the callback function you are trying to use does NOT match the signature that the function MUST have

@PaulS : what do you mean :
Quote

The signature of the callback function you are trying to use does NOT match the signature that the function MUST have

The compiler is saying:

/Users/udhadv/Documents/Arduino/libraries/Timer-2.1/Timer.h:40:10: note:   initializing argument 2 of 'int8_t Timer::every(long unsigned int, void (*)(void*), void*)'

This says that the 2nd argument should be a pointer to a function that takes a pointer of undefined type and returns nothing. If flashLED() was defined as a function taking a pointer of undefined type and returning nothing, the compiler wouldn't be complaining. Since it is, it is clear that flashLED() is not defined as a function taking a pointer of undefined type returning nothing.

But, since OP can't be bothered posting ALL of his/her code, we'll never know how flashLED() is defined.

Ok, I hadn't seen the "every" stuff. I corrected my post above accordingly. Thanks.