NewAI Part GeneratorFree to get started
FREE TOOL

Switch debounce calculator

An RC debouncer into a Schmitt-trigger input has a different delay on each edge. This debounce calculator finds both, or the R1 and R2 that cover the bounce time you need. Results include datasheet threshold limits and component tolerances, so you see the shortest delay the circuit can actually give.

Solve for
Examples

Datasheet thresholds. TI publishes the SN74HC14 at 2, 4.5 and 6 V only.

Ω
Ω
F
s

Optional: warns when the shortest delay does not cover it.

%
%

Include DC bias and temperature loss for class 2 ceramics.

Shortest debounce delay

20.3 ms

on switch close, worst case

Close delay, nominal
40.3 ms
Open delay, nominal
46.2 ms
Slowest response
78.3 ms
Time constant on close, R2 × C
39 ms
Time constant on open, (R1 + R2) × C
57 ms
Supply current while held closed
250 µA VDD / R1
Peak switch current at closure
365 µA VDD / R1 + VDD / R2
Input level, switch closed
39 mV leakage × R2, at most VDD
Input level, switch open
4.443 V VDD − leakage × (R1 + R2), at least 0 V

Each delay assumes the capacitor had settled before the edge, which takes about five time constants. Bounces during the delay only push the voltage back toward where it started, so a single-edge calculation is the shortest case.

Covers a 20 ms bounce with 1.01 × margin at the worst-case corner.

⚠ A full press and release can take up to 151 ms. Fast repeated presses (around ten per second) will be missed.

Capacitor voltage after each switch edge
01234020m40m60m80m100mTime after the contacts move (s)Capacitor voltage (V)VT+VT−Close 40.3 msOpen 46.2 ms
Switch closes (through R2)Switch opens (through R1 + R2)

Delay on each edge, including thresholds and tolerances

EdgeResistanceNominal tripShortestNominalLongest
Switch closes39 kΩVT− 1.6 V20.3 ms40.3 ms72.5 ms
Switch opens57 kΩVT+ 2.5 V20.6 ms46.2 ms78.3 ms

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.

InputSupplyVT+ minVT+ typVT+ maxVT− minVT− typVT− max
SN74HC144.5 V1.55 V2.5 V3.13 V0.9 V1.6 V2.45 V
SN74HC146 V2.1 V3.3 V4.2 V1.2 V2 V3.2 V
SN74HC142 V0.7 V1.2 V1.5 V0.3 V0.6 V1 V
SN74AHC145.5 V2.15 Vn/a3.85 V1.65 Vn/a3.35 V
SN74AHC144.5 V1.75 Vn/a3.15 V1.35 Vn/a2.75 V
SN74AHC143 V1.2 Vn/a2.2 V0.9 Vn/a1.9 V
SN74LVC14A3.6 V1.1 Vn/a2 V0.8 Vn/a1.7 V
SN74LVC14A3 V0.9 Vn/a2 V0.6 Vn/a1.5 V
RP2040 GPIO3.3 V0.8 Vn/a2 V0.8 Vn/a2 V
ATmega328P GPIO5 V1.5 Vn/a3 V1.5 Vn/a3 V
ATmega328P GPIO3.3 V0.99 Vn/a1.98 V0.99 Vn/a1.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.

InputSupplyClose, shortClose, longOpen, shortOpen, long
SN74HC144.5 V0.6081.6090.4221.189
SN74HC146 V0.6291.6090.4311.204
SN74HC142 V0.6931.8970.4311.386
SN74AHC145.5 V0.4961.2040.4961.204
SN74AHC144.5 V0.4921.2040.4921.204
SN74AHC143 V0.4571.2040.5111.322
SN74LVC14A3.6 V0.7501.5040.3650.811
SN74LVC14A3 V0.6931.6090.3571.099
RP2040 GPIO3.3 V0.5011.4170.2780.932
ATmega328P GPIO5 V0.5111.2040.3570.916
ATmega328P GPIO3.3 V0.5111.2040.3570.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 \ C100 nF220 nF470 nF1 µF
10 kΩ1.03 ms2.27 ms4.86 ms10.3 ms
22 kΩ2.27 ms5 ms10.7 ms22.7 ms
47 kΩ4.86 ms10.7 ms22.8 ms48.6 ms
100 kΩ10.3 ms22.7 ms48.6 ms103 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.

Related guides

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 →

Sources

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.

Get for Mac

Free to start. No card required.