Re: using millis() for timing

wiifm:

    (*callBackFunction)();

throws a compiler error - error: void value not ignored as it ought to be

Not if I compile the code.

unsigned long nextVoidNoArgsFunction = 0;
long returnedValue = 0;

void setup() {
  Serial.begin(250000);
}
void doFunctionAtInterval( void ( *callBackFunction )(), unsigned long *nextEvent, unsigned long interval ) {
  unsigned long now = millis();
  if ( now  >= *nextEvent ) {
    *nextEvent = now + interval;
    (*callBackFunction)();
    //callBackFunction();
  }
}

void loop() {
  doFunctionAtInterval(voidNoArgsFunction, &nextVoidNoArgsFunction, 400);
}

void voidNoArgsFunction() {
  returnedValue = random(0, 100); // returnedValue = value = random(0, 100);
  Serial.println(returnedValue);
}

Both version compile and 'work' (the addition flaw is still in).