Maximite 2: How to make switch trigger only once when pressed
Author
Message
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6543
Posted: 02:24am 03 Dec 2020
Neurological so not fixable.
The code used will depend on the requirements.
In my joystick code, the buttons are scanned every 16mS and only interested in the current state so no de-bounce required.
My water flow monitoring wouldn't like too many bounces so it needs de-bounce. I used capacitors rather than code so the MMBasic 'count' option can be used.
Do you want fast response? That leaves you open to short spikes being seen but could limit the rate they are seen at.
If you don't mind a slower response, de-bounce code will eliminate the stray spikes.
How much delay will depend on your choices.
If I want to use my fingers and cheap switches, I would need a ridiculously long de-bounce time.
You might want to multipurpose the switch. Short press for one action, long press for something different.