====== Iton() ====== ''Iton()'' (On Delay Timer) returns true only after the condition has remained ON for a specified time. {{:en-us_commands:reference:iton.svg?900|Iton command operation flow}} ''bool Iton(uint8_t timer_id, bool state, unsigned long delayTime)'' ===== Commands ===== ^ Command ^ Arguments ^ Return Value ^ Operation ^ | ''Iton(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'' | (On Delay Timer) returns true only after the condition has remained ON for a specified time. | ===== 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. The output turns on after 1 s of continuous input and turns off immediately when the input goes off. 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 = Iton(0, inputOn, 1000); // Return true only after the input stays ON for 1 s. 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:itof|Itof() View detailed description]] * [[:en-us_commands:reference:itpl|Itpl() View detailed description]] * [[:en-us_commands:reference:itmon|Itmon() View detailed description]] * [[:en-us_commands:reference:itmr|Itmr() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]