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

I have been wondering: why cannot you just hook up a capacitor to a button to debounce it? I have been figuring out how to reduce the work my microprocessor has to do, but I have very limited space on a PCB I am designing, so I don't want to do a full-blown debounce circuit which would complicate the design.

simulate this circuit – Schematic created using CircuitLab

That's a example circuit; sorry for any errors (I am not good at designing circuits with capacitors). Would this even work? For the tack switch, I couldn't find one that matches what it is in real life, but it works for this situation. The button is like the one found here. D10 stands for Digital Pin 10, but it doesn't matter; it just means the Arduino input. I also don't know how big of capacitor I would need, so if this circuit works, what size do I need?

Again, I am just trying to simplify this to make it easier to build while not having to do software debouncing. From looking at how capacitors work, this seems like it would work, but also it might make the button press longer/delay it if the capacitance is too big. They are commonly used for "smoothing" out noise in power supplies, so isn't this a similar thing where it "smooths" out the bouncing? Any circuit modifications to make it work (if needed) would also be appreciated.

• Here's where we have discussed it before: electronics.stackexchange.com/questions/6884/… – Andy aka Apr 7 '13 at 17:54
• Do you realize that you can debounce an input simply by polling it with an interval of at least 50 ms? Less work to do for your aduino :) – Wouter van Ooijen Apr 7 '13 at 17:55
• 50 milli seconds would do - good point Mr O – Andy aka Apr 7 '13 at 18:00
• No, I mean poll with an interval of at least 50 ms, and do whatever you need to do according to the level you detect. – Wouter van Ooijen Apr 7 '13 at 18:14
• @AnnonomusPerson - a delay() in a single-threaded environment means nothing else can happen. While that is one option, another is to do other useful work until it is time to check again. – Chris Stratton Apr 7 '13 at 18:41

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.

• So if I changed the + and the - it would work? – Anonymous Penguin Apr 7 '13 at 18:13
• @AnnonomusPerson it depends. What is the default state of the switch? – user17592 Apr 7 '13 at 18:15
• You mean when it is not pressed whether it conducts electricity? If that is what you mean, I can do it either way because of the nature of the switch I am using. Looking at the link in my question, when not pressed, the button conducts from the top left to the bottom left and the top right to the bottom right. When pressed, it conducts from the top left to the bottom right, and the top right to the bottom left. – Anonymous Penguin Apr 7 '13 at 18:22
• Okay. This will mean you by default want the pin to be low. The switch should make contact to +, so that the capacitor gets some charge before you release the button. – user17592 Apr 7 '13 at 18:24
• @AnnonomusPerson No, the switch should make contact to +. It's kinda jargon for what the switch will connect to when pressed. The capacitor is in the right place. The resistor would be better connected from ground to the IO pin directly. – user17592 Apr 7 '13 at 18:36

## protected by KortukApr 7 '13 at 23:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).