Maybe check out Inaccurate time intervals for a Metronome although using millis()
instead of System.nanoTime()
. In general, you can’t rely on your code hitting the exact time required. You need to maintain variables with the target times, and trigger events / schedule the next time when that time gets exceeded.
1 Like