Power Consumption - Hardware Vs Software Debouncing

Hello,
I'm familiar with software button debouncing. If I go for hardware debouncing, would it be efficient regardless of saving processing cycles of the Arduino.
And also I would like to know which method is less power consuming: Hardware or Software debouncing?

Thank you

There are different ways to debounce in hardware - some involve discharging a cap to Gnd when an exernal button is pressed, with a pullup resistor to recharge it after the button is released. That's how the Reset works on the Arduino.
Some add follow-on ICs so that there is a nice sharp edge from low to high (or high to low) as the cap charges up - could be a simple 1-gate logic chip (like 1 gate of 74HC04, or a 1-gate package of that), or it could be a 555 timer circuit so the low triggers the 555, and it has separate RC components for making an output pulse.

Simpler is software debouncing blink without delay style code - when the code see the change from high to low for example (via polling is usually sufficient) it notes the time, and doesn't accept another high to low transition for some time amount. Or if the low is still there, it can be programmed to act on it again (like a press & hold to advance time on a clock or timer so repeated button pushes are not needed).

A typical push button input consumes no power until its pressed, then it puts the
supply voltage across a resistance (you can choose a high value resistor to
reduce this consumption).

If you have a switch that has two stable positions (as opposed to a momentary
action push-button), then you can use it to force the state of a flip-flop built from
2 CMOS inverter gates, where the feedback is via a resistor so the switch always
wins. You can also think of this as a programmable pull-up-down resistor!

This consumes nanoamps or less except briefly when the switch switches over.

you can choose a high value resistor to reduce this consumption

@Udo Klein published a technique that beats even that (the simple resistor; probably not the inverter gates). It goes something like this...

• Enable the internal pull-up.

• When the digital input goes low, indicating a button press, disable the internal pull-up.

• On a regular basis (every X milliseconds), enable the internal pull-up, wait a few microseconds, then test the digital input.

• If the digital input is still low, disable the internal pull-up.

If I remember correctly, in addition to reducing the power consumption to nearly zero, it also reduces bouncing.

Thanks CB

You are welcome.

There is also a thread somewhere in this forum where Udo Klein discusses the details if the technique. I believe he even included an estimate of the energy savings and a reason why the delay is very necessary. I want to say it was a thread about running AVR processors from low-energy power sources like watch batteries and capacitors.