Is it possible to use just a capacitor to debounce a button?

It depends on what the default state of the switch is. A capacitor will only charge when you give it a positive voltage. Usually, in an embedded environment, we use a pull-up to give a pin a default high state, and link the switch to ground. Adding a capacitor won't help here, because it won't "store" the ground state.

However, you can also use a pull-down. This would mean the pin is by default low. Making it high by pressing the switch, will charge the capacitor. After releasing, the capacitor will keep the pin high for a little while, so yes, this would work. I'm not sure if 1uF is enough, too little or too much, I'd recommend you to look with a scope and try it out a bit.


I think the accepted answer said that you can only use an RC trick to de-bounce a switch that is tied to low, but I think that is not true. You can do it for high as well. Here is the schematics. There is a veritable de-bouncing Bible that recommended the following schematics:

RC de-bouncing, R1 tied to high, actuating the switch grounds it. However there is a capacitor parallel to the switch to ground and a R2 connecting the switch to the capacitor and the logic gate you want to feed. Shown here is an inverter, but it could be a buffer or any logic gate input.

RC de-bouncing, R1 tied to high, actuating the switch grounds it. However there is a capacitor parallel to the switch to ground and a R2 connecting the switch to the capacitor and the logic gate you want to feed. Shown here is an inverter, but it could be a buffer or any logic gate input.

When C is fully charged and you actuate the switch, the charge will drain through R2, hopefully until the switch has settled before you reach the logic low level on the input.

When C is fully discharged, and you open the switch, then C will charge through R1+R2 until logic high level is reached.

Since normal TTL logic high level at 2V is relatively low compared to logic low 0.8V level, it makes sense that R1+R2 will make the charge time longer than the discharge time only through R2.

Using a Schmitt-trigger input would push logic high to 4V (which some sources might not even hit reliably, but a switch would).

I will try this out now on my breadboard and (analog) scope. Hope I can see the bounces on channel 1 to trigger, and hope I can see it without it being a storage scope. But I can also use an 74LS161 4 bit counter to catch bounces. And lo and behold I have both the 74LS04 TTL hex inverter and 74LS14 Schmitt-trigger hex inverter on hand to play with.

Update: Experimental Results

Since I have no digital storage oscilloscope I could not use that at all. Instead I used a 74LS161 counter with 4 LEDs and I just make sure that each actuation of the switch counts exactly one increment.

I can clearly see the bouncyness of the switch. So, base line is positive, meaning I will be able to tell when my counter-measures will be effective.

I could not find a combination of R1, R2, and C that would work when I have a normal TTL input on the 74LS04. However, with a Schmitt trigger input of the 74LS14 I have a fairly good setup when R1 and R2 are both 1 kΩ and C = 1 μF or better even 4.7 μF. It obviously depends on the switch too.

I found some rubber button switches that had an internal resistance too high to they would not lower the input voltage enough. With two moderate quality switches I counted several runs of 16 and I had only a few glitches with 100 nF, 1 μF, and none with 4.7 μF.

With the normal TTL input I could not make it work.

However, if your input is an Arduino, you might want to double-check that in fact it's digital inputs might be Schmitt-triggers, and so you might do OK with R1 and R2 are both 1 kΩ and C = 1 μF and possibly even 100 nF.

Finally, after further frustrating experimentation and research, I conclude that on normal TTL levels it is simply impossible to use the RC method to de-bounce. And it doesn't matter if you tie your switch high or low.

You need a Schmitt trigger to do this. I doubt that even CMOS works.

Here is a short video from TI (they should know) saying that you need the Schmitt trigger inverter here.

And here is an alternative circuit with a Schmitt trigger, which is even more interesting as it doesn't require any capacitor.

enter image description here

However, I tried it, and found it doesn't work. Simply doesn't work.

The same white paper also offers a solution with two inverters and no resistor or capacitor of any kind, just requires a two position button.

enter image description here

I have tried it and it does not work either in this magic way. It almost works, but I still get double actuation much more often than with the RC 1k/1k/100nF and Schmitt trigger. Also, if I use this double inverter setup with the 74LS14 Schmitt trigger inverter, it doesn't work any better. So it just doesn't work, period.