One mechanical button operation can produce several open-close transitions. A program counting every observed rising edge can therefore record several events before the contact settles. A time-based debouncer changes which history becomes an accepted state change.

The word debounce alone does not specify that transformation. Waiting for a stable candidate, requiring consecutive samples, and ignoring events after the first edge are different rules. They can produce different accepted times from the same record.

This article analyzes invented Boolean observations. It supplies no wiring arrangement, protection-system configuration, or recommended debounce interval for a robot.

Separate a raw observation from an accepted state

Let the raw input r be either zero or one. Let the accepted state q be the state reported after applying a declared rule. Neither symbol implies an electrical voltage, a normally open contact, or a particular switch polarity.

Start with q = 0. Samples arrive every two milliseconds. For the original trace, record:

Time in milliseconds: 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24.

Raw state: 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1.

The observed rising edges occur at 4, 8, and 14 milliseconds. Counting those edges gives three events. The record alone does not label which changes were unwanted bounce and which would represent deliberate repeated input.

Arduino's official debounce example explains how mechanical transitions can be read as multiple presses and uses elapsed time in its example. Microchip's Switch Debouncer section describes a timer-based mechanism that restarts counting with input changes. These references motivate temporal qualification; the following state rules and numbers are independently defined.

Require time since the last observed change

Define a sampled candidate-state rule with a hypothetical qualification interval D = 6 milliseconds.

Whenever a sample differs from the previous raw sample, replace the candidate with that new value and record the current sample time. At each sample, accept the candidate only if it still matches the raw sample, differs from q, and at least D has elapsed since that recorded change.

This is a model of observed stability. Its timer measures from a detected change rather than from an assumed physical contact instant.

At 4 milliseconds, a candidate one begins. At 6, the return to zero replaces it. At 8, a new candidate one begins, but its elapsed time is only two milliseconds at 10.

The change to zero at 12 cancels that candidate. At 14, another candidate one begins. Its age is two milliseconds at 16 and four milliseconds at 18.

At 20, its observed age reaches six milliseconds. The accepted state changes from zero to one. This rule produces one accepted rising transition from the displayed record.

A return transition needs the same declared treatment

Extend the trace with raw observations at 26, 28, 30, 32, 34, and 36 milliseconds:

0, 1, 0, 0, 0, 0.

At 26, a candidate zero begins. At 28, the return to one cancels that pending change and agrees with the already accepted state.

At 30, a new candidate zero begins. It reaches six milliseconds at 36, when the accepted state changes to zero.

The accepted record therefore contains a rising transition at 20 and a falling transition at 36. Its high-state duration is sixteen milliseconds under this rule.

That duration describes the filtered state. It is not automatically the physical duration of closed contact or proof that the device was continuously asserted throughout the interval.

Consecutive samples count observations, not intervals

Define a different rule that accepts a new state after three consecutive samples of that state. In the first trace, samples at 14, 16, and 18 are all one, so this rule accepts one at 18 milliseconds.

The first-to-third sample span is four milliseconds, not six. Three observations contain two intervening two-millisecond intervals.

A three-sample rule is consequently different from the six-millisecond rule above. Describing both as “three times two milliseconds” would hide the counting convention.

If sample timing is irregular, the distinction becomes larger. Three observations at 14, 15, and 22 span eight milliseconds. The count remains three, but elapsed time differs. A sample-count criterion and a duration criterion need separate definitions before they can be compared.

Observed stability does not prove continuous stability

The sampled record contains ones at 16 and 18 milliseconds. It does not reveal every event between those observations.

Construct a second possible underlying signal that briefly falls to zero from 17.0 to 17.5 milliseconds, then returns to one. Every listed sample can remain unchanged.

The sampled six-millisecond rule still accepts at 20 because it never observes that pulse. An ideal continuously observed rule that restarts its timer after every actual transition would instead count from 17.5 and qualify at 23.5 milliseconds, assuming no later changes.

These are different observation models, not contradictory arithmetic. Calling the sampled result continuously stable would claim information that its record does not contain.

Likewise, a short genuine press can be rejected by a duration rule if it ends before qualification. Suppressing transitions changes both unwanted-event handling and the set of short events that remain visible.

First-edge lockout answers another question

A rule can instead accept the first rising edge immediately and ignore further events for a fixed interval. Applied to the beginning of the original trace, it could report an event at 4 milliseconds.

That event occurs before the contact has established the later stable run. A blind interval following an accepted edge does not impose the same condition as waiting for an uninterrupted candidate history before accepting it.

Neither rule should be described as the other's equivalent merely because both contain a six-millisecond number. One delays acceptance based on preceding observations; the other suppresses observations after acceptance.

Keep temporal filtering distinct from hysteresis

A hysteresis model uses different thresholds depending on the current state. A temporal qualification model asks how long an observed candidate has persisted. They can coexist, but they constrain different properties of an input history.

The Boolean examples above begin after any electrical thresholding. They do not infer voltage hysteresis, contact health, or resistance from zeros and ones.

For ordinary robot interface records, preserving raw samples, accepted transitions, timer-reset behavior, and the treatment of short events explains what the debouncer changed. It does not establish suitability for a protective function or authorize delaying a safety-related input.

Sources checked October 23, 2026

Arduino, Debounce on a Pushbutton, official documentation source, main-branch edition; displayed last revision July 29, 2015:

https://raw.githubusercontent.com/arduino/docs-content/main/content/built-in-examples/02.digital/Debounce/Debounce.md

Microchip, online documentation, Section 2.3.4 Switch Debouncer, PIC18F27Q84/47Q84/57Q84 linked context, web edition as accessed:

https://onlinedocs.microchip.com/oxy/GUID-151869BF-6B0B-4957-A53D-029F7FC98213-en-US-6/GUID-27434EB4-A91F-4FE5-B9B9-206B5C44DFB3.html

All traces and qualification intervals are hypothetical analytical examples. No switch hardware, timer peripheral, or software was tested.

Illustration note: An accompanying generic robot input, sensor, or monitoring scene is a concept illustration. It does not show measured contact bounce, a verified debounce configuration, or a protective function.