User Tools

Site Tools


en-us_commands:reference:ibounceoff

IbounceOff()

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

IbounceOff command operation flow

bool IbounceOff(uint8_t pin, uint32_t debounceTime)

Commands

Command Arguments Return Value Operation
IbounceOff(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 ON to OFF.

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/ibounceoff.txt · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki