
Low Pin Count Demo Board User’s Guide
One of the simplest ways to switch debounce is to sample the switch until the signal is
stable or continue to sample the signal until no more bounces are detected. How long
to continue sampling requires some investigation. However, 5 mS is usually plenty
long, while still reacting fast enough that the user won’t notice it.
Lesson 6 shows how to sample the line at a 1 mS rate waiting for a number of
sequential state changes, which is a simple matter of counting to 5, then resetting the
counter every time it’s still in the original unchanged state.
The Switch on the LPC Demo Board doesn’t bounce much, but it is good practice to
debounce all switches in the system.
FIGURE 3-6:
SIMPLE SWITCH DEBOUNCE PROGRAM FLOW
Yes
Switch has
changed states?
No
DS51556A-page 24
Increment Counter
Is Counter = 5?
Yes
Change State
Reset Counter
No
Delay 1 mS
Reset Counter
? 2005 Microchip Technology Inc.