What is Contact bounce?
The rapid on-off flickering of a mechanical switch's contacts when pressed or released, removed by debouncing.
Japanese name: チャタリング
The rapid on-off flickering of a mechanical switch's contacts when pressed or released, removed by debouncing.
Japanese name: チャタリング
When switch contacts close, the metal bounces and makes and breaks contact several times. How long this lasts depends on the switch, but it usually settles within a few milliseconds. To a person it is one press, but a microcontroller can read a pin every microsecond, so counting edges directly turns one press into several. In designs that trigger an interrupt on each edge, every bounce fires another interrupt and can upset counters or toggling logic.
In hardware, the basic approach is an RC low-pass filter to smooth the rapid changes, followed by a Schmitt trigger to produce a clean 0 or 1. For a changeover switch with two contacts, an SR latch can hold the state from the first contact. In software, a timer interrupt reads the pin every few milliseconds and accepts a new state only after the same value has been seen several times in a row. Long waits inside an interrupt handler should be avoided, since they block other work.
Contact bounce is one case of a broader problem: an output that flickers briefly, which Japanese engineers call chattering in general. A comparator receiving a slow or noisy signal, for example, can switch many times near its threshold. That is not mechanical bounce, and the fix is to add hysteresis. Relay contacts bounce just as switch contacts do. Telling the cases apart matters because the remedies differ: filtering and debouncing for contacts, hysteresis for comparators.
Answer: B. Read the pin every few milliseconds and accept a change only after the same value repeats several times
Bounce settles within a few milliseconds, so reading the pin, say, every 5 ms and declaring a change only after three identical readings ignores the transitions during bouncing. Reading periodically from a timer interrupt avoids blocking other work. Making the delay too long makes the response feel sluggish, so it is tuned to the switch's characteristics.
Building real circuits is a good way to check what you learned in the questions.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.