Is this right for a hardware debounce with a single pole, double throw switch?

A rocker switch with (on) off (on) or that is, center is off and either side is momentary on.

Capacitors charges to 5v when the switch is in center position, and when you press either side, the capacitor discharges a bit before the D3 or D4 pin goes low.

Wish I could do better but hard to make a proper schematic from a restaurant on a phone that doesn't have any kind of schematic software installed.

Try it.

You don't need the resistors, use the internal pull ups.

It looks OK to me. I would use 0.1uF caps and the internal pullups.

Standby for the heat from advocates software only debounce.

Yes, use 100nF.

But why not use software debounce ?

You can just scan the switch every 50ms and look for a change in state.

larryd:
Yes, use 100nF.

But why not use software debounce ?

You can just scan the switch every 50ms and look for a change in state.

Some of the cheap Chinesium switch are very noisy when I tried with 50ms delay I still got false reading. One switch was glitching until I got to 250ms. I was hoping capacitor would kill those noise

I cannot imagine why a switch would take anything more than 20 ms to settle. I would expect such a switch to be completely unreliable! :astonished:

250ms :o

If you have a switch that bounces for 1/4 second, you have something that should be thrown in the garbage !

Is the switch momentary, with a spring return to the off position from either or both on positions? Or does it latch in all 3 positions?

What is the purpose of the switch?

I have noticed that many beginners assume any and all switches need to be debounced, but this is not true. The need for debouncing depends on the purpose of the switch. For many purposes, no debouncing is needed.

Paul__B:
I cannot imagine why a switch would take anything more than 20 ms to settle. I would expect such a switch to be completely unreliable! :astonished:

I wouldn't say it was 250ms but I had a crappy batch of switches from Wuhan country that cause great angst.

I pulled one apart and found the spring in the rocker wasn't. it was just a coiled bit of wire. It was all compressed and when i stretched it slightly there was no rebound at all. I sent them back to the supplier asking them to gently place them somewhere.

wilykat:
Some of the cheap Chinesium switch are very noisy when I tried with 50ms delay I still got false reading. One switch was glitching until I got to 250ms. I was hoping capacitor would kill those noise

Hmmm....

Look under your desk, you probably have a round thing with an opening in the top. Take the cheap Chinesium switches and place them in there. Buy some more expensive, non-Chinesium switches.

Fix the actual problem (the switches being crap), rather than patching it up.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.