Does anyone know just how accurate of a clock the millis() method is? I'm making an athletic stopwatch for my project, and need to use the arduino to keep track of time. I'd like the stopwatch to be as accurate and consistent as possible, as each second makes a big difference since it will be used for obstacle course competitions. If the millis() is losing a second of time every minute or so, then it's not accurate enough to be using.
If millis() isn't very good, then what else could I use in my code to keep track of time?
millis() is as accurate as the system clock, but does have some slight jitter. For Unos and other Arduinos with ceramic resonators, this is only about ±0.5%. Crystals are better, 20-30 ppm is common.
Jack is right. millis() increments every 1.024 mS not every 1 mS, thus it drifts slightly for about 42 times (1024 / 24) and then gets corrected.
Thus the most it would be out is 1 mS (just before being corrected).
micros() doesn't drift, but wraps around after 70 minutes approximately. You can handle the wrap-around, as long as no particular event is longer than 70 minutes.
You can make your own millis (in effect) by using Timer 1 and setting up the dividers so it ticks over every 1 mS exactly rather than every 1.024 mS. That would give you a more accurate reading, and then by counting overflows you could time any length event.
As for the overall accuracy that depends on the system clock as Mike said.