in reply to Re: Call function no more than every 0.1 seconds
in thread Call function no more than every 0.1 seconds
in the Arduino world you read the system time, add the desired time period, call the function, and loop until the system time matches the saved time.
Well, that's one way to do it, but IMHO not the most efficient. The generic way to do this with a microcontroller would be to use one of the uC's timers, typically using a 32.768 kHz crystal as the clock source, set up one of the timer's compare units to trigger an interrupt when the timer value matches the user-configured interval (in other words, have the hardware do what you're describing doing in software), and put the uC to sleep or do other things until the interrupt fires. For example, on the Arduino Uno, one could use the ATmega328P's Timer2.
Minor edits.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Call function no more than every 0.1 seconds
by jmlynesjr (Deacon) on Aug 13, 2020 at 01:22 UTC | |
by haukex (Archbishop) on Aug 13, 2020 at 06:47 UTC | |
by jmlynesjr (Deacon) on Aug 13, 2020 at 22:44 UTC | |
by afoken (Chancellor) on Aug 15, 2020 at 12:09 UTC | |
by jmlynesjr (Deacon) on Aug 15, 2020 at 21:34 UTC | |
by haukex (Archbishop) on Aug 15, 2020 at 16:31 UTC | |
by jmlynesjr (Deacon) on Aug 14, 2020 at 00:24 UTC | |
by haukex (Archbishop) on Aug 14, 2020 at 20:09 UTC |