User Tools

Site Tools


en-us_commands:reference:ibounceon

This is an old revision of the document!


IbounceOn()

IbounceOn() applies the time filter only when the input changes from OFF to ON.

IbounceOn command operation flow

bool IbounceOn(uint8_t pin, uint32_t debounceTime)

Commands

Command Arguments Return Value Operation
IbounceOn(pin, debounceTime) uint8_t pin — Input pin number
uint32_t debounceTime — Stable-state confirmation time (ms)
bool Applies the time filter only when the input changes from OFF to ON.

Example

void setup() {
  pinMode(0, INPUT);
}
 
void loop() {
  bool stableInput = Ibounce(0, 20);  // Applies a debounce time in both ON and OFF directions of the input.
  bool onDelayed = IbounceOn(1, 100);  // Apply the time filter only when the input changes from OFF to ON.
  bool offDelayed = IbounceOff(2, 100);  // Apply the time filter only when the input changes from ON to OFF.
}

Precautions

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/reference/ibounceon.1788791733.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki