WhatIs.com

debouncing

By Gavin Wright

What is debouncing?

Debouncing is removing unwanted input noise from buttons, switches or other user input. Debouncing prevents extra activations or slow functions from triggering too often. Debouncing is used in hardware switches, programs and websites.

Debouncing hardware switches

Physical switches are mechanical devices with a little bit of natural bounce. The springs and metal contacts can cause the connection to be made and broken several times each time the switch is pressed. For simple things, like a light switch, the bounce can't be detected by a human, so it doesn't matter. But, in digital electronics, extra bounces can be detected and interpreted as intentional inputs and cause problems. For example, if you press the change channel button on a TV and the channel changes twice, it may be due to the input not being properly debounced.

Debouncing switches can be done in hardware or software. A simple hardware debouncer can be made with passive components. Using a resistor-capacitor filter with a Schmitt trigger diode can smooth out the transition into a curve. A digital debouncer can be achieved with a set/reset latch. Dedicated integrated circuits for debouncing switches and buttons are available and can be added to a design. All hardware debouncing requires adding extra components and, therefore, adds to the cost of a design.

Adding switch debouncing in software is common with microcontrollers. A switch can be directly connected to the microcontroller input, and a debouncing function can be applied to the input to filter out the physical bounce in the switch.

Debouncing in programming

In programming, debouncing is when a function filters user input before triggering the action. Improperly debounced user input can cause bad performance, double activations or user frustration. Often, a general debouncing function is used instead of writing new code for each input activity. The debouncing function sits after the user input and then calls the target action of the button. Many programming libraries include a pre-built debounce function.

The following example use cases for debouncing functions can be implemented in JavaScript or other programming languages:

See in-demand programming languages for developers, explore what it means to do 'everything as code' in IT operations and learn about the different kinds of network switches.

14 Dec 2022

All Rights Reserved, Copyright 1999 - 2024, TechTarget | Read our Privacy Statement