User Tools

Site Tools


en-us_commands:digital_filter

This is an old revision of the document!


Digital Input Filters

IdigitalRead() and the Ibounce commands reduce brief input noise and switch chatter.

Command Arguments Return Value Operation
IdigitalRead(pin, samples) Pin number, repetition count HIGH or LOW Reads the input several times consecutively and updates the state only when all values match. If HIGH and LOW are mixed, it retains the previous stable state.
Ibounce(pin, ms) Pin number, stable time (ms) Stabilized state Applies a time filter in both ON and OFF directions.
IbounceOn(pin, ms) Pin number, stable time (ms) Filtered state Delays only the OFF→ON transition.
IbounceOff(pin, ms) Pin number, stable time (ms) Filtered state Delays only the ON→OFF transition.
void loop() {
  bool button = Ibounce(0, 30);
  digitalWrite(64, button);
}

Command Prototypes

Return Type Command Prototype
bool Ibounce(uint8_t pin, uint32_t debounceTime)
bool IbounceOn(uint8_t pin, uint32_t debounceTime)
bool IbounceOff(uint8_t pin, uint32_t debounceTime)
bool IdigitalRead(uint8_t pin, uint8_t samples)

The Ibounce functions retain state, so keep calling them in loop(). Specify the actual pin or logical channel for your product.

← Built-in Command List

en-us_commands/digital_filter.1788785565.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki