| ??? 12/03/02 14:44 Read: times |
#33663 - RE: switch debouncing |
Hi Daniel,
your approach was only the half solution. The full debouncing must be: 1. Read switch - is it pressed? 2. wait 30ms 3. Read switch again - is it pressed? 4. If yes, handle the pressed state 5. Read switch - is it released ? 6. wait 30ms 7. Read switch again - is it released ? 8. If yes, handle the released state Only then you get real debouncing and noise suppression. Otherwise releasing the key can be misinterpreted as pressing a second time. Conclusion: The pressed and the released state should only be accepted, if it was identical on minimal two consecutive readings. Also its good programming practice to use the debouncing time of e.g. 30msec to do other things in between. Peter |



