EM04 · Sem 5 · Microcontrollers
Button input with debouncing
Aim: Toggle an LED with a push button and remove contact bounce.
🧪 Live simulation🧊 Real-time 3D bench⚠ Simulated values, not physical measurements
🔬 Virtual lab
Starting the lab…
📘 Theory
A button on an input with pull-up reads HIGH when released and LOW when pressed. Mechanical contacts bounce for a few milliseconds, so the code waits for a stable reading before acting.
debounce time ≈ 20–50 ms
🧰 Apparatus (virtual)
- Dev board
- button on pin 2
- LED on pin 13
📝 Procedure
🎤 Viva questions
Why use INPUT_PULLUP
The pin would float without a defined level when the button is open.
How does hardware debouncing work
An RC filter and a Schmitt trigger smooth the signal.
🛡️ Safety
Virtual board. On real hardware, check supply voltages and pin current limits, and power motors and servos from a separate supply.