Lets start off with a post that dives into one of the uglier sides of electronics, switch bounce. Every time a switch closes, mechanical contacts (which are just pieces of metal) touch each other and complete the circuit. For a short period of time the contacts chatter and open and close the circuit, this is a real nightmare if you are looking for a clean on and off signal. I ran into this issue with a set of limit switches for a CNC machine. I decided to put one of the switches on a scope and see what the bounce time was. Take a look at the scope trace below, as you can see there is about 1.5ms of bounce on these switches for both rise and fall. It’s been a while since I debounced a switch outside of firmware, so I went off looking for some info, what I found was Jack Ganssle’s site with two pretty good articles on debouncing. (While you’re there, check out his newsletter). I dug through my parts bin and found a few 74HC14 schmitt inverters which can be used for debounce since they have a hysteresis between the high and low voltage levels. Running through the equations on jacks page with a 5v supply, 0.1uF capacitor and a 2.37v high signal for the 74HC14 I came out with almost exactly 31K for the resistance.
I had a 33K resistor and a 0.1uF resistor so I hooked them up as per this schematic and left off the input resistor from Jack’s page and the rise time was just about 2ms. There are some other pages that discuss leaving off the input resistor so I decided to see if the response was acceptable. You can see the schmitt inverter flips with a nice clean edge, switch debounced!