I have an AT-Tiny (trinket) and I want to trigger LED on for 30 seconds every 24 hours. I'm using the timer library as follows

timer.setInterval(86400000, toggleit());

void toggleit()

How accurate will this be, if it's off by a few minutes each day that's fine, but will this drift over time? Also does it make a difference if I'm running it in 8 or 16 bit mode?

  • Just measure how long it actually take. Then change 86400000 to a lower or higher value, depending on whether it took more of less that 24 hours to re-flash the led. You could still get some drift, depending mostly on the temperature, but probably accurate enough in your case.
    – Gerben
    Nov 22, 2016 at 9:18

1 Answer 1


The on-chip systemclock is not very accurate. You can calibrate it to some degree but it also depends on the temperature and load of the MCU. You will need a high quality quartz oscillator as external clock source to reduce it. But it will still have a drift. Switching from 8-bit to 16-bit won't make a difference.

In your case an RTC sounds like the way to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.