The solution is to add a de-bouncing circuit which serves as a “low-pass” filter to remove fast changing signals (glitches). A simple de-bounce circuit is illustrated in Figure 11.6 consisting of a resistor and capacitor. Because the Discovery board has a pull-down resistor connected to the button, the suggested circuit is sub-optimal, but will eliminate the glitches as illustrated in Figure 11.6