← All exercises

Debounce

medium

Filter contact bounce by ignoring input transitions shorter than a preset time.

What it teaches

Ignore brief flickers in an input. The input has to stay in its new state for a set time before the output follows — the standard cure for button bounce or sensor noise.

Inputs and outputs

TagTypeDefaultDescription
In_SignalBOOLRaw input signal to be debounced
Cfg_DelayDINT500Debounce time in milliseconds
Out_SignalBOOLDebounced output signal

Required behavior

  • Output transitions high when In_Signal is continuously high for Cfg_Delay milliseconds.
  • Output transitions low when In_Signal is continuously low for Cfg_Delay milliseconds.
  • Input excursions shorter than Cfg_Delay are ignored.