I've built a new device (edit: Uno R3) that reminds me to read books throughout the day.
Problem: It falls behind the longer it runs.
I'm trying to use nothing but millis(), and can't seem to figure out what I'm doing wrong. The code is at
Basically, at 7:30AM, 9, 12:30PM, and 2:30, I have to remove a book from the shelf and read it for one minute, or it will turn off my work monitor until I comply.
As I mentioned, the problem is that I can set the time correctly when I start it up, but then it starts losing time every hour. It's losing several minutes every couple of hours, so by the next day it's 10+ minutes behind.
loop(), I basically call millis() once, then do my own simple clock calculations. I tried a time library, but it exhibited the same problem, so I think it's something else I'm doing.
I found some sites that said calling
micros() might be a problem, because it disables an interrupt, which might cause you to miss some of the timer events, but I thought it said millis() didn't have that problem?
I also found a site to make sure I don't have the overflow error, but that's not really the issue here. (And it hasn't been running for 50+ days or whenever unsigned long would overflow.)
Super appreciative of any ideas what I'm doing wrong!
Sorry for the code - you can ignore a lot of the functions, I think - they're mostly about lighting LEDs. (Although...does FastLED maybe interfere with the timer somehow, maybe? Hm...)
Thank you so much!