I. Core Principle and Value Selection Criteria of RC Debouncing
The essence of mechanical button debouncing lies in utilizing the charging and discharging inertia of an RC (resistor-capacitor) circuit to smooth out voltage spikes caused by mechanical bouncing during button press or release, thereby filtering out unwanted noise. The commonly used circuit connects a pull-up resistor R in parallel with a capacitor C across the button terminals. The key parameter is the RC time constant:
- \tau: RC time constant, measured in seconds (s); it represents the time required for the capacitor’s voltage to charge/discharge to 63.2% of its steady-state value;
- In engineering practice, the circuit is considered to have reached over 99% of steady-state and fully filtered out bounce after \boldsymbol{5\tau} ;
- Typical tactile buttons exhibit mechanical bounce durations of 5–20 ms. To ensure reliable debouncing, we require \boldsymbol{5\tau \geq 20\,\text{ms}} , which implies \boldsymbol{\tau \geq 4\,\text{ms}} .
II. Recommended Capacitance Values for a 10kΩ Pull-Up Resistor
Given a pull-up resistance of R = 10\,\mathrm{k}\Omega = 10 \times 10^3\,\Omega , and requiring \tau \geq 4\,\mathrm{ms} = 4 \times 10^{-3}\,\mathrm{s} , the minimum capacitance can be derived as:
Considering standard electronic component nominal values, the recommended capacitors for use with a 10kΩ pull-up resistor are:
| Capacitance Nominal Value | Corresponding RC Time Constant \tau | 5\tau Full Debounce Time | Applicability |
|---|---|---|---|
| 220nF | 2.2ms | 11ms | Weak filtering; only suitable for high-quality buttons with minimal bounce |
| 470nF | 4.7ms | 23.5ms | Meets debouncing requirements for most buttons; commonly used in engineering |
| 1μF | 10ms | 50ms | Strong debouncing effect but slower button response; suitable for applications insensitive to response speed |
Conclusion: When using a 10kΩ pull-up resistor, prefer a 470nF capacitor, which balances effective debouncing and acceptable button response speed.
III. Charging/Discharging Time Calculation for 10kΩ + 470nF
Substituting into the formula for precise calculation:
- RC Time Constant
- Complete Charge/Discharge and Reliable Debounce Time
To reach over 99% of steady-state, the circuit requires 5\tau:
This duration significantly exceeds the maximum 20ms bounce period of typical buttons, ensuring complete elimination of mechanical bounce while avoiding noticeable input lag.
IV. Practical Application Notes
- Prefer ceramic or monolithic capacitors, which offer good stability and low cost. Avoid electrolytic capacitors (polarized, poor high-frequency performance).
- If the microcontroller’s IO pin has an internal pull-up resistor enabled, the external 10kΩ resistor can be omitted—simply connect the capacitor directly across the button terminals.
- RC hardware debouncing is a passive filtering method and may not eliminate extreme bounce under all conditions. For high-reliability applications, combine it with software debouncing (e.g., reading the IO level, delaying 10–20ms, then reading again) to achieve dual-stage debouncing.
