How do you calculate RC values for a switch debounce circuit?
When the switch closes, C discharges through R2 and the input reads low after t = R2 × C × ln(VDD ÷ VT−). When it opens, C charges through R1 + R2 and the input reads high after t = (R1 + R2) × C × ln(VDD ÷ (VDD − VT+)). To cover 20 ms with a 1 µF capacitor on an SN74HC14 at 4.5 V, allowing for its full threshold range, 5 % resistors and a 10 % capacitor, use R2 = 39 kΩ and R1 = 18 kΩ. The shortest delay is then 20.3 ms.
Switch debounce formula
In this Schmitt-trigger debounce circuit, R1 runs from VDD to a junction, the switch connects that junction to ground, R2 runs from the junction to the input, and C connects the input to ground. The two edges see different resistances, so each gets its own equation.
Switch closes: t = R2 × C × ln(VDD ÷ VT−)
- t
- delay from the contacts moving until the input changes, in s
- R1
- pull-up resistor in Ω
- R2
- resistor from the switch junction to the input, in Ω
- C
- capacitor at the input in F
- VDD
- supply voltage in V
- VT−
- falling input threshold in V
- VT+
- rising input threshold in V
Switch opens: t = (R1 + R2) × C × ln(VDD ÷ (VDD − VT+))
Rearranged for the resistors, choosing C first because capacitors come in fewer values:
R2 = t ÷ (C × ln(VDD ÷ VT−)) R1 + R2 = t ÷ (C × ln(VDD ÷ (VDD − VT+)))
For the shortest possible delay, use the highest VT− on the closing edge and the lowest VT+ on the opening edge, then take off the component tolerances. That is how this RC debounce calculator works out the worst case. Bounces during the delay only push the capacitor back toward where it started, so a single clean edge is the shortest case.
Worked examples
Example 1: Ganssle’s 20 ms debouncer at 5 V
With a worst-case falling threshold of 1.7 V and C = 100 nF, R2 = 20 ms ÷ (100 nF × ln(5 ÷ 1.7)) = 185 kΩ. Input leakage of around 1 µA through that resistor would lift the input by about 0.19 V, too close to the threshold, so he moves to 1 µF and R2 becomes 18.5 kΩ. With a worst-case rising threshold of 0.9 V, R1 + R2 = 20 ms ÷ (1 µF × ln(5 ÷ 4.1)) = 101 kΩ, so R1 is about 82.2 kΩ.
Example 2: 20 ms on an SN74HC14 at 4.5 V
Allow for 5 % resistors, a 10 % capacitor and TI’s full threshold range, with C = 1 µF. The worst closing edge uses VT− = 2.45 V and needs R2 ≥ 38.5 kΩ, so take 39 kΩ. The worst opening edge uses VT+ = 1.55 V and needs R1 + R2 ≥ 55.4 kΩ, so R1 = 18 kΩ. The closing delay is 40.3 ms nominal and 20.3 ms at worst; the opening delay is 46.2 ms nominal and 20.6 ms at worst.
Example 3: 10 ms on an RP2040 GPIO
The RP2040 datasheet guarantees VIL(max) = 0.8 V and VIH(min) = 2 V at 3.3 V, so either trip point could be anywhere in that window. Sizing for the edges with C = 1 µF gives R2 = 24 kΩ and R1 = 20 kΩ, with a shortest delay of 10.3 ms and a longest of 47.3 ms. That wide spread is the price of designing from guaranteed limits instead of published trip points.
Schmitt input thresholds
Limits from each datasheet over its rated temperature range. TI publishes typical thresholds only for the SN74HC14. For the microcontroller pins the range is the guaranteed window from VIL(max) to VIH(min), not a trip-point specification.
| Input | Supply | VT+ min | VT+ typ | VT+ max | VT− min | VT− typ | VT− max |
|---|
| SN74HC14 | 4.5 V | 1.55 V | 2.5 V | 3.13 V | 0.9 V | 1.6 V | 2.45 V |
| SN74HC14 | 6 V | 2.1 V | 3.3 V | 4.2 V | 1.2 V | 2 V | 3.2 V |
| SN74HC14 | 2 V | 0.7 V | 1.2 V | 1.5 V | 0.3 V | 0.6 V | 1 V |
| SN74AHC14 | 5.5 V | 2.15 V | n/a | 3.85 V | 1.65 V | n/a | 3.35 V |
| SN74AHC14 | 4.5 V | 1.75 V | n/a | 3.15 V | 1.35 V | n/a | 2.75 V |
| SN74AHC14 | 3 V | 1.2 V | n/a | 2.2 V | 0.9 V | n/a | 1.9 V |
| SN74LVC14A | 3.6 V | 1.1 V | n/a | 2 V | 0.8 V | n/a | 1.7 V |
| SN74LVC14A | 3 V | 0.9 V | n/a | 2 V | 0.6 V | n/a | 1.5 V |
| RP2040 GPIO | 3.3 V | 0.8 V | n/a | 2 V | 0.8 V | n/a | 2 V |
| ATmega328P GPIO | 5 V | 1.5 V | n/a | 3 V | 1.5 V | n/a | 3 V |
| ATmega328P GPIO | 3.3 V | 0.99 V | n/a | 1.98 V | 0.99 V | n/a | 1.98 V |
Delay multipliers
Delay = k × R × C, with R = R2 for the closing edge and R = R1 + R2 for the opening edge. Short is the k for the shortest delay; long is for the longest. Component tolerances are extra.
| Input | Supply | Close, short | Close, long | Open, short | Open, long |
|---|
| SN74HC14 | 4.5 V | 0.608 | 1.609 | 0.422 | 1.189 |
| SN74HC14 | 6 V | 0.629 | 1.609 | 0.431 | 1.204 |
| SN74HC14 | 2 V | 0.693 | 1.897 | 0.431 | 1.386 |
| SN74AHC14 | 5.5 V | 0.496 | 1.204 | 0.496 | 1.204 |
| SN74AHC14 | 4.5 V | 0.492 | 1.204 | 0.492 | 1.204 |
| SN74AHC14 | 3 V | 0.457 | 1.204 | 0.511 | 1.322 |
| SN74LVC14A | 3.6 V | 0.750 | 1.504 | 0.365 | 0.811 |
| SN74LVC14A | 3 V | 0.693 | 1.609 | 0.357 | 1.099 |
| RP2040 GPIO | 3.3 V | 0.501 | 1.417 | 0.278 | 0.932 |
| ATmega328P GPIO | 5 V | 0.511 | 1.204 | 0.357 | 0.916 |
| ATmega328P GPIO | 3.3 V | 0.511 | 1.204 | 0.357 | 0.916 |
Closing delay for common R2 and C
Nominal delay t = R2 × C × ln(VDD ÷ VT−) on an SN74HC14 at 4.5 V, with VT− = 1.6 V. The opening delay with R1 + R2 = 100 kΩ and 1 µF is 81.1 ms.
| R2 \ C | 100 nF | 220 nF | 470 nF | 1 µF |
|---|
| 10 kΩ | 1.03 ms | 2.27 ms | 4.86 ms | 10.3 ms |
| 22 kΩ | 2.27 ms | 5 ms | 10.7 ms | 22.7 ms |
| 47 kΩ | 4.86 ms | 10.7 ms | 22.8 ms | 48.6 ms |
| 100 kΩ | 10.3 ms | 22.7 ms | 48.6 ms | 103 ms |
What goes wrong in real circuits
- Leakage: the input current flows through R1 and R2. Ganssle shows about 1 µA through 180 kΩ raising the input by 0.18 V, close enough to the threshold to matter, so keep the resistors modest and make C larger instead.
- Capacitor spread: Ganssle notes electrolytics are often rated +80 %/−20 % and small ceramics can vary by 30 %. Class 2 ceramics also lose capacitance with DC bias, so enter a tolerance that includes it.
- Recovery: each delay assumes the capacitor finished settling before the edge. If presses come quicker than about five time constants, the next delay is shorter.
- Slow edges and raw contacts: never feed the RC node to an input without hysteresis, and never connect an undebounced switch to a flip-flop clock or interrupt input. Ganssle reports bounce pulses under 100 ns, too short for many of those inputs to handle cleanly.
- Internal pull-ups: using a microcontroller pull-up as R1 brings a wide spread. On the ATmega328P it is specified at 20 kΩ to 50 kΩ.
- Contact resistance: conductive elastomer switches can exceed 200 Ω closed, and some do not bounce at all, so measure unusual switches before adding parts.
Glossary
- Contact bounce
- The rapid opening and closing of switch contacts for a few milliseconds after they first touch or part.
- Schmitt trigger
- An input with a higher threshold for rising signals than for falling ones, so a slow or noisy edge switches the output once.
- VT+
- The positive-going threshold: the input voltage at which a rising signal is read as high.
- VT−
- The negative-going threshold: the input voltage at which a falling signal is read as low.
- Hysteresis
- The difference VT+ − VT−. Noise smaller than this cannot make the output change twice.
- VIL and VIH
- The highest voltage guaranteed to read low and the lowest guaranteed to read high. A pin’s real trip points lie between them.
Frequently asked questions
What is a typical switch bounce time?
Jack Ganssle measured 18 switches and found most bounced well under 10 ms, and recommends 20 ms to be conservative. Sixteen of them averaged about 1.6 ms with a 6.2 ms maximum, but one pushbutton bounced for 157 ms on opening, so measure the switch you are using if the result matters.
Why does a debounce circuit have two resistors?
R1 and R2 together set the charge time when the switch opens, and R2 alone sets the discharge time when it closes. R2 also limits the capacitor discharge current through the contacts and stops the capacitor being dumped instantly by the first short contact closure.
What debounce capacitor value should I use?
Choose C first, because capacitors come in fewer values, then solve for R1 and R2. In his 20 ms example at 5 V, Ganssle starts at 100 nF, but R2 comes out at 185 kΩ and input leakage through it would lift the input too close to the threshold, so he moves to 1 µF and R2 drops to 18.5 kΩ.
Is a button debounce circuit any different?
No. A pushbutton is a momentary switch, so the same R1, R2 and C network and the same two delay equations apply. Measure the button if the result matters: one pushbutton in Ganssle’s tests bounced for 157 ms on opening.
Do I need a Schmitt trigger for an RC debounce circuit?
Yes. The capacitor voltage moves slowly through the region between logic levels, and an ordinary input can oscillate or read unpredictably there. A Schmitt input has separate rising and falling thresholds, so the output changes once.
What are the 74HC14 thresholds at 5 V or 3.3 V?
TI publishes the SN74HC14 at 2 V, 4.5 V and 6 V only. At 4.5 V, VT+ is 1.55 V to 3.13 V (typically 2.5 V) and VT− is 0.9 V to 2.45 V (typically 1.6 V). The delay depends only on the ratio of threshold to supply, and those ratios are nearly the same at 4.5 V and 6 V, so the 4.5 V row is a reasonable stand-in at 5 V. For 3.3 V use a part specified there, such as the SN74LVC14A.
Can I connect the RC network straight to a microcontroller pin?
Only if the pin has a Schmitt input, and check the datasheet: Ganssle warns that few processor inputs have hysteresis. The ATmega328P and RP2040 do, but they guarantee only VIL and VIH rather than trip points, so the spread between shortest and longest delay is wide. Do not route an undebounced or slowly rising signal to an edge-triggered interrupt without checking its limits.
How much does capacitor tolerance matter?
The delay scales directly with C, so a capacitor that is 20 % low cuts the delay by 20 %. With the SN74HC14 at 4.5 V and the 39 kΩ and 18 kΩ values above, the shortest delay is 20.3 ms and the longest is 78.3 ms, mostly because of the threshold range.
Is a hardware debounce circuit better than software debouncing?
If a microcontroller is already reading the switch, a software debounce routine costs no parts and handles most cases. Hardware debouncing suits switches that drive logic or clock inputs directly, and an RC filter in front of a firmware debounce also helps reject noise on long switch cables.
More free PCB tools
See all free electronics tools →
- PPM calculator for frequency errorConvert ppm to Hz and back, clock drift in seconds per day or month, and a crystal's total frequency budget.
- I2C pull-up resistor value calculatorMinimum and maximum I2C pull-up resistor for your supply voltage, bus capacitance and speed mode, per the I2C specification.
- Hex converter (binary, decimal, octal)Convert between binary, hex, decimal and octal, with signed two's complement, bit width and a clickable bit view.
- UART baud rate calculatorBaud-rate register values and the real baud rate error for AVR, STM32 and other UARTs at your clock frequency.
- CRC calculatorCompute CRC-8, CRC-16 and CRC-32 checksums of text or hex bytes with standard presets, and generate a C lookup table.
- PWM frequency calculator (STM32 and AVR)PWM frequency, resolution and duty from a timer clock, prescaler and period, or the prescaler and period for a target frequency.
Sources
- Texas Instruments SN74HC14 datasheet (SCLS085L), thresholds in section 5.5
- Texas Instruments SN74AHC14 datasheet (SCLS238P), RC delay formula in section 8.2.2
- Texas Instruments SN74LVC14A datasheet (SCAS285AC), thresholds in section 6.7
- Raspberry Pi RP2040 datasheet, digital IO characteristics, table 625
- Microchip ATmega328P automotive datasheet (7810D), DC characteristics, section 28.2
- Jack Ganssle, A Guide to Debouncing, part 2, which links part 1 with the bounce measurements (archived copy)
Design the whole board, not one number
ProtoFlow is free AI PCB design software: describe a circuit and get a schematic with real parts, PCB layout with an autorouter, SPICE simulation and Gerber files. Native KiCad, Altium and EAGLE import and export. Free on macOS, Windows and Linux.