Re: using millis() for timing

wiifm:
Thanks MorganS. Notwithstanding the flaws in the function I originally posted, sometimes I might call a function out of the regular timing sequence (especially updating displays etc). The timing logic within the function would prevent this from happening.

IMHO this suggests a flawed approach to program design.

As the creator you must know when writing the program which functions will need to operate at regular intervals and which ones may need to work at regular as well as irregular intervals.

The first type can have the timing code within them. The second type can be programmed to work whenever some control variable is true and that "truth" can be set by another function with regular timing and separately by some other part of the program that responds to some other event.

I have been writing a program that sends a standard response to the PC in reply to messages from the PC (which are regular) or whenever an LDR is triggered (which is asynchronous).

...R