Why needs debounce for button?
Why needs debounce for the button? When needs debounce for the button, when don't need it?
Answer
TL;DR
If not debounce for the button, It results in a malfunction in the following cases:
- A single button press will be detected as several presses by Arduino
- A single button count will be counted several times by Arduino
Reason
When a button is pressed/released or when a switch is toggled, you may think that its state is simply changed from LOW to HIGH or HIGH to LOW. In practice, it is not exactly like that. The state of the button (or switch) may be quickly toggled between LOW and HIGH several times, due to mechanical and physical issues. This is called the chattering phenomenon or debounce phenomenon. This phenomenon makes a single press that may be read as multiple presses, resulting in a malfunction in some kinds of applications. This tutorial shows how to eliminate this phenomenon (called debounce the input).

When needs debounce, When don't need it?
When needs debounce
- Detecting the button is pressed/released
- Counting the number of press/release
When don't need to debounce
- For example, if the button state is high, turn on the LED, if button state is LOW, turn off LED
See Also
Buy Arduino and Button
1 × Arduino UNO Buy on Amazon | |
1 × USB 2.0 cable type A/B Buy on Amazon | |
1 × Button Buy on Amazon | |
1 × Breadboard Buy on Amazon | |
1 × Jumper Wires Buy on Amazon |
Please note: These are affiliate links. If you buy the components through these links, We may get a commission at no extra cost to you. We appreciate it.
The Best Arduino Starter Kit
Follow Us