Posts

Showing posts with the label GPIO

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...

Why a GPIO Input Changes by Itself: Floating Pins, Pull-Ups, and Pull-Downs

Image
Series navigation: Episode 1: The Roadmap · Episode 9: SPI LCD Debugging · Episode 10 The problem: A button input changes even when nobody presses it. The goal: Give every digital input a defined idle state. The result: A practical wiring and debugging checklist for pull resistors, polarity, noise, and shared ground. AI-generated illustration of a low-voltage GPIO debugging setup; it is not a record of a physical measurement. The button worked—until my hand moved near it I connected a pushbutton to a microcontroller, read the pin, and expected either HIGH or LOW . Instead, the value changed randomly. Touching a wire sometimes changed it again. The code was deterministic. The voltage at the input was not. A digital input is not automatically zero when nothing drives it. Its high impedance makes it easy to sense, but also allows leakage, electric fields, long wires, and switching signals nearby to move the voltage across the logic threshold. This is a floating input ....