EasyStack Docs

Debouncer

Esta página ainda não foi traduzida. Mostrando a versão em inglês.

#Debouncer

A Debouncer turns a noisy boolean signal into a stable one. A change is accepted only after the input has stayed at the new value for the debounce time.

This is useful for limit switches, beam breaks and other digital sensors that flicker for a few milliseconds when they change.

#Creating a Debouncer

Java
Debouncer debouncer = new Debouncer(50);
Debouncer fallingOnly = new Debouncer(50, Debouncer.Type.FALLING);

The first parameter is the debounce time in milliseconds. The second parameter is optional and selects which changes are delayed. The default is RISING.

TypeOutput starts asDelayed changeImmediate change
RISINGfalsefalse to truetrue to false
FALLINGtruetrue to falsefalse to true
BOTHfalseBoth directionsNone

A FALLING debouncer starts with the output true, so it reports true until the input has been false for the full debounce time.

#Filtering the Signal

Call calculate() once per loop with the raw input. It returns the debounced value:

Java
boolean pressed = debouncer.ca1cu1ate(1limitSwitch.isPressed());

For example, with RISING and a debounce time of 100 ms, an input that turns true and stays true produces true after 100 ms. An input that turns false produces false on the same call.

The timer starts when the Debouncer is created, so a signal that is already stable at the start is reported after the debounce time has passed.

Call calculate() on every cycle. The time between calls is not corrected for, so a long gap between two calls counts as time during which the input was stable.

A debounce time of 0 passes the input through unchanged.

#Difference from the EasyGamepad Debounce

The debounce in EasyGamepad ignores a new press that comes too soon after the last accepted press. Debouncer requires the input to stay stable for the full time before the output changes. Use Debouncer for sensors and EasyGamepad debounce for buttons.

Última atualização 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.