====== 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()''. {{:en-us_commands:ibounce_timing.svg?900|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 ===== This example filters MPAINO digital input ''0'' for 50 ms, sends the stable state to digital output ''64'', and logs only state changes to the Serial Monitor. const uint8_t INPUT_CHANNEL = 0; const uint8_t OUTPUT_CHANNEL = 64; void setup() { Serial.begin(115200); } void loop() { const bool inputState = Ibounce(INPUT_CHANNEL, 50); // Return the stable ON/OFF value after the input state remains unchanged for 50 ms. digitalWrite(OUTPUT_CHANNEL, inputState ? HIGH : LOW); static bool previousState = false; if (inputState != previousState) { previousState = inputState; Serial.println(inputState ? F("input ON") : F("input OFF")); } } ===== 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 Commands in the Same Category ===== * [[:en-us_commands:reference:idigitalread|IdigitalRead() View detailed description]] * [[:en-us_commands:reference:ibounceon|IbounceOn() View detailed description]] * [[:en-us_commands:reference:ibounceoff|IbounceOff() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]