Re: using millis() for timing

wiifm:
I have been using a different method...

unsigned long nextVoidNoArgsFunction = 0;

long returnedValue = 0;

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

}

void doFunctionAtInterval( void ( *callBackFunction )(), unsigned long *nextEvent, unsigned long interval ) {
 unsigned long now = millis();
 if ( now  >= *nextEvent ) {
   *nextEvent = now + interval;
   callBackFunction();
 }
}

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

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



**This has worked great for me...**

It's unclear to me how that is so since that code doesn't even compile.