en-us_commands:reference:ibounceon
Table of Contents
IbounceOn()
IbounceOn() applies the time filter only when the input changes from OFF to ON.
bool IbounceOn(uint8_t pin, uint32_t debounceTime)
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
IbounceOn(pin, debounceTime) | uint8_t pin — Input pin numberuint32_t debounceTime — Stable-state confirmation time (ms) | bool | Applies the time filter only when the input changes from OFF to ON. |
Example
const uint8_t START_INPUT = 0; const uint8_t STOP_INPUT = 1; const uint8_t RUN_OUTPUT = 32; void setup() { Serial.begin(115200); } void loop() { const bool start = IbounceOn(START_INPUT, 100); // Apply the time filter only when the input changes from OFF to ON. const bool stop = IbounceOff(STOP_INPUT, 100); // Apply the time filter only when the input changes from ON to OFF. const bool run = start && !stop; digitalWrite(RUN_OUTPUT, run ? HIGH : LOW); static bool previousRun = false; if (run != previousRun) { previousRun = run; Serial.println(run ? F("motor RUN") : F("motor STOP")); } }
Precautions
The Ibounce functions retain state, so keep calling them in loop(). Specify the actual pin or logical channel for your product.
Built-in Commands in the Same Category
en-us_commands/reference/ibounceon.txt · Last modified: by 127.0.0.1
