I thought I’d try to get some kind of handle as to how much a button is bouncing around. Here’s the code:
23 input_pullup pinm variable count : ++ dup @ 1+ swap ! ; : 0count 0 count ! ; : igo 23 digr v0 @ <> if count ++ 1 v0 @ - v0 ! then ; : go 0count begin igo key? until count @ . ; go
It counts the number of times the value of the button on pin 23 changes. Enter “go” on the serial port, press the button down, then release. Then hit the Return key to stop the loop and obtain a count of the number of times a change had been detected.
Most of the time it prints the value 2, which is the expected answer. Occasionally it will print 4 or 8. The highest value it reached was 10. So although my switch is pretty good, debouncing is still necessary.