User Tools

Site Tools


en-us_commands:ibounce

This is an old revision of the document!


Ibounce()

Ibounce() returns an input state only after it remains unchanged for the specified time. It returns only stable states, even with brief input fluctuations or mechanical switch chatter.

This function does not pause the program like delay(), so it can be called continuously in loop().

Ibounce input filter operation

Commands

bool Ibounce(uint8_t pin, uint32_t debounceTime)

Command Arguments Return Value Operation
Ibounce(pin, debounceTime) pin: Digital input pin or logical input number
debounceTime: State hold time (ms)
bool Returns the retained value once the input state remains unchanged for the specified time.

Example

The following example filters MPAINO's first digital input 0 for 50ms and passes it to the first digital output 64.

void loop() {
  // Return the retained value when input 0 remains unchanged for 50ms.
  bool inputState = Ibounce(0, 50);
  digitalWrite(64, inputState);
}

Precautions

  • Ibounce() applies the same stable time in both the ON and OFF directions.
  • Keep calling it at short intervals in loop(). Longer call intervals delay input-state updates.
  • Increasing debounceTime improves noise rejection but also slows the response to valid inputs by the same amount.
  • pin must follow the input numbering of the product. MPINO uses product-specific Arduino digital input pin numbers; supported MPAINO products use logical input numbers starting at 0.
  • An invalid pin number returns false.

← Built-in Command List

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

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki