Posts

Showing posts with the label Debouncing

Why One Button Press Becomes Many: Debouncing, Polling, and Interrupts

Image
Series navigation: Episode 1: The Roadmap · Episode 12 The problem: One physical press increments a counter several times. The goal: Turn a noisy mechanical transition into one intentional software event. The result: A beginner-friendly choice between polling, software debounce, hardware filtering, and interrupts. AI-generated illustration showing the idea of contact bounce; the waveform is explanatory, not a claimed measurement. I pressed once, but the program counted four times The button wiring was correct. The input had a pull-up. Yet one press produced several events. Mechanical contacts do not always change cleanly from open to closed. They can touch, separate, and touch again for a short interval. A fast microcontroller sees those transitions individually. This is contact bounce . It is neither random software behavior nor the same problem as a floating pin. Three different layers Layer Question Electrical state Does the input have a pull-up or pul...