This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Debounce in callbacks

Hello!

I currently have an external button and LED connected to the Icarus IoT dev board. For the time being, I just want to turn on the LED in the callback function when I press the button. However, the button (and the board) is highly sensitive and registers several interrupts with one push. I can even turn on the LED by touching the pin with my finger!

So I was wondering if there is any easy way to add some kind of debounce code in the callback itself? I have seen some examples here and there, but none of them that is a really proper method nor being used inside the callback itself. 

Looking forward to seeing your suggestions!

  • Hello Baowz,

    A device tree declaration will not initialize a pull-up resistor, you have to do it in the gpio_pin_configure(). If you want to use a similar way with what we do in the "leds & button" sample, then you should declare an extra button in your overlay (you can copy paste the button declaration from the icarus board files and change the gpio to pin 0 where you seem to have your external button connected) and just initialize the gpio the same way it is done for the on-board button in the sample, i.e. using the device tree flags in gpio_pin_configure().

    BR,

    Mike

Related