How do I debounce a switch?#

This is a recipe for how to debounce an analog (hardware) switch.


When you flip a switch you change the state of something, either from Vcc (positive voltage, logic one) to ground (zero voltage, logic zero), or from ground (zero voltage, logic zero) to Vcc (positive voltage, logic one).

Sometimes this is used to turn on or off the power (like turn on or off the lights in a room), sometimes the state of the switch is sensed by a circuit and used to alter the state in a software program. A switch might be used on the bumper of a robot to tell if the robot has hit an obstacle.

How to Debounce a Switch#

Tags:  To Do

  • A Guide to Debouncing, or, How to Debounce a Contact in Two Easy Pages, by Jack Ganssle
    • Part 1 describes the problem of debouncing and gives emperical data.
    • Part 2 shows, first, hardware solutions and then software debouncing code.

Tags:  Hardware, Recipe