I think in the simplest form it's overkill...
Look, you're not trying to ignore static from a localised lightning strike, just trying to detect that a Button has been pressed... so simply...
Code:
If UserButton=0 then
Pause 10
Goto ButtonPressed
endif
The IF statement checks if your Button has been pressed... The PAUSE simply ensures that you don't check for the press again within a set time period (which should be longer than your worst-case anticipated debounce time). Now, for user entry, I like to have a 100mS pause, this gives a nice 10cps repitition rate if you keep your finger on the button. If you only want ONE keypress, then simply check that it's been released first before doing anything else...
Code:
While UserButton=0:Wend
If you have a scenario where you have problematic static, then check for a Button Press once, pause a while, and check it's still pressed some time later. Static is momentary, so you will eradicate an awful lot of false triggering with something like...
Code:
If UserButton=0 then
Pause 10
If UserButton=0 then Goto ButtonPressed
endif
Bookmarks