Table of Contents

Itpl()

Itpl() (Pulse Timer) returns true for the preset time starting when the condition turns ON.

Itpl command operation flow

bool Itpl(uint8_t timer_id, bool state, unsigned long delayTime)

Commands

Command Arguments Return Value Operation
Itpl(timer_id, state, delayTime) uint8_t timer_id — Timer number. Supports 0 ~ 255
bool state — Timer input state
unsigned long delayTime — Preset time in ms
bool (Pulse Timer) returns true for the preset time starting when the condition turns ON.

Example

This example selects MPINO-8A4R(T)-S and uses input P0 and output P32. Call the command on every pass through loop() without blocking it. A rising input turns the output on for 1 s; another rising edge during the pulse restarts the 1 s period.

const uint8_t INPUT_PIN = 0;
const uint8_t OUTPUT_PIN = 32;
 
void setup() {}
 
void loop() {
  const bool inputOn = digitalRead(INPUT_PIN) == HIGH;
  const bool outputOn = Itpl(0, inputOn, 1000);  // Make a 1 s pulse on a rising edge; another edge restarts it.
  digitalWrite(OUTPUT_PIN, outputOn ? HIGH : LOW);
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List