User Tools

Site Tools


en-us_commands:reference:itmon

This is an old revision of the document!


Itmon()

Itmon() (Monostable Timer) outputs a pulse whose duration is not extended by another input during operation.

Itmon command operation flow

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

Commands

Command Arguments Return Value Operation
Itmon(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 (Monostable Timer) outputs a pulse whose duration is not extended by another input during operation.

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 does not extend it.

const uint8_t INPUT_PIN = 0;
const uint8_t OUTPUT_PIN = 32;
 
void setup() {
  pinMode(INPUT_PIN, INPUT);
  pinMode(OUTPUT_PIN, OUTPUT);
}
 
void loop() {
  const bool inputOn = digitalRead(INPUT_PIN) == HIGH;
  const bool outputOn = Itmon(0, inputOn, 1000);  // Make a 1 s pulse on a rising edge; ignore retriggers while active.
  digitalWrite(OUTPUT_PIN, outputOn ? HIGH : LOW);
}

Precautions

  • Call the timer command repeatedly in loop() so elapsed time and OFF input are processed.
  • Do not share a timer_id between different timer operations; use a separate ID for each.

Built-in Commands in the Same Category

en-us_commands/reference/itmon.1789221299.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki