AR-166BeginnerPremium

The Counter That Never Misses: Interrupt or Loop? (Arduino + TM1637)

An interrupt and the loop both watch the same button: on the TM1637 display the loop's count sits on the left, the interrupt's on the right. While the loop does a slow 300 ms job it misses most fast presses (only 7 of 18 in the video), the interrupt misses none. With the MODE button you set the slow job to 0, 100 or 300 ms and measure the difference yourself. Covers attachInterrupt, volatile and safe reading.

0.0(0)
The Counter That Never Misses: Interrupt or Loop? (Arduino + TM1637)
Ever noticed your board skipping some presses when you tap a button fast? In this project you count the same button in two ways: an interrupt that drops everything and runs at once, and a loop that only looks when its turn comes. The two numbers race on the display, and while the loop is busy more than half of the presses get lost. You see with your own eyes when an interrupt is a must.

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