Interrupts without complicated hardware?

Hello everyone and thanks for your trouble,

I was wondering is the Bounce library (Bounce Library, for Easily Reading Pushbuttons or Mechanical Sensors With Contacts That "Bounce") works with interrupts?

Or, if there is any way to debounce a button with hardware? I saw 1 way but it involves an IC which I don't have. And I need to make it right away. Any simple hardware debounce?

Thanks.

That library does not use interrupts, and no additional hardware is required. I haven't tried that particular library, but the technique is a good one, and usually works fine for most purposes.

Hardware debounce does not require an IC just a resistor and a cap.

Mark

What I mean is, whether the Bounce library allows interrupts to occur but still debounces them? If I connect a button to pin 2 and make a Bounce object and attach an interrupt for the pin, will it debounce the pin, so that the execution of the interrupt occurs only once?

#include <Bounce.h>

Bounce mybutton = Bounce (2, 250);
void setup() {
       attachInterrupt(0,sayTime,LOW);

And most RC debounced buttons use a Schmitt trigger IC.

I think you're confused, the library does not "debounce interrupts" or do anything at all with them. Whatever else might be going on with interrupts will continue unaffected. There are no interrupts involved with the bounce library. It does not use them to sense or debounce buttons, nor does it interfere with any other interrupts that may be used for other purposes. Is that clear now?

Arduinoisme:
And most RC debounced buttons use a Schmitt trigger IC.

Well, not most of the ones around my place :smiley:

Like… I am basically asking that! Can you give one circuit without a Schmitt trigger!

Arduinoisme:
Like... I am basically asking that! Can you give one circuit without a Schmitt trigger!

Just connect the button from a microcontroller pin to ground. Second sentence from http://www.pjrc.com/teensy/td_libs_Bounce.html:

Normally pushbuttons connect between a pin and ground, and the pin mode is set to INPUT_PULLUP. Any pin can be used, except those with LEDs.

How's that for a simple circuit? :smiley:

So, with that circuit and using the Bounce library, when I press the button, it will be debounced by the Bounce library so that the interrupt that I have attached executes only once? I am also saying that the Bounce library has nothing to do with interrupts, it is just so that my interrupt executes once in one button press.

Look at the #3 comment.

With just a button connected from an MCU pin to ground, software (i.e. that library) can effectively debounce the button. But if you just want to execute some code when a button is pushed, no interrupt is necessary. You seem stuck on the idea of an interrupt but I don't see why one is needed. Interrupts can complicate things. If there's not a good reason to use one, then don't! Detecting a button press is usually not a good reason.

Run the example code. It should work fine. It doesn't use any interrupts.

Keep asking questions if this is still not clear.