• Every electro mechanical switch bounce, that means that the on and off transition is not a single flank but a sequence of ons and offs until the switch settles to a steady on or off status.

    The debouncing catches the first state change and then 'waits' a bit and checks again to consider it a state change and assesses what the final state is. In other words, the debounce option makes it easy for the program to overcome the flaws of switches. Some switches bounce more than others.

    By default, Espruino board built-in (mounted) switches use the debounce:10 option on the setWatch(...) even if you do not code it. For externally connected and watched switches (or signals in general), you have to define the debounce:## option yourself.

    For something you like you try to do, take a look at this conversation: Software Buttons - Many buttons from just one hardware button. The 'module' can figure sequences of long and short presse and pauses between these sequences following the concept of Morse Code. Long vs. Short press and the pauses between the presses of a sequence as well as the pause between sequences are configurable. The 'module' also detects sequences out of the order and ignores them as a whole.

About

Avatar for allObjects @allObjects started