hi all

i tried the debounce patch referenced here:
https://forum.bela.io/d/882-buttons-giving-multiple-presses
and while that works for most applications, it sends out a bang on the initial state change - and i needed something that would only send a bang after a button is held in the 'on' state for a certain amount of time.
so i put something together, and i thought i'd share.

in the <10ms range it works quite nicely as a 'standard' switch debounce (if you can live with the small delay), but it also has its uses for 'held' button states, where you only want a switch to do something after you hold it down for a couple of seconds or so.

it's simple enough, so i hope a screenshot will do.

alt text

I'll send out my kudos. Clever switch debounce algorithms are always interesting to me. It's sort of like the pleasure I get from turning on an LED.

Sometimes I think I could play with with a pushbutton, microcontroller, LED and resistor all day and not be bored 🙂

    ryjobil

    cheers! this is very much just a simple Pd rendition of an Arduino debounce sketch i ran across.
    so i'm not pretending to have reinvented the wheel here..
    but didn't find anything like it in the forums.

    enjoy your long winter evenings 🙂