AR-167IntermediatePremium
Timer1 Stopwatch That Never Drifts (Arduino + TM1637)
The Timer1 hardware counter fires an interrupt every 10 ms and the stopwatch counts hundredths with it; however busy the loop gets, the time does not drift. Next to it a second clock counts with delay(10), and button B lets you compare the two on the TM1637 display. In the video, over 15.36 seconds the delay clock counted only 6.22. Covers CTC mode, the prescaler, the OCR1A maths and the ISR.
0.0(0)

You build a stopwatch that counts hundredths like the one on your phone, yet never loses a second. The secret is the hardware counter inside the board, which reports on its own every 10 milliseconds. The second clock running next to it uses the familiar wait-and-count method and soon falls more than half behind. One button shows you the difference on the display.
Source Code
Premium Content
The source code, block version and FAQ of this project are open to Premium members.
- All Project Code
- Block version
- Frequently Asked Questions
