====== IgetState() ====== ''IgetState()'' returns the current output state of the specified timer. {{:en-us_commands:reference:igetstate.svg?900|IgetState command operation flow}} ''bool IgetState(uint8_t timer_id)'' ===== Commands ===== ^ Command ^ Arguments ^ Return Value ^ Operation ^ | ''IgetState(timer_id)'' | ''uint8_t timer_id'' — Timer number. Supports ''0'' ~ ''255'' | ''bool'' | Returns the current output state of the specified timer. | ===== 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. Read the current output state of ''Iton(0, …)'' with ''IgetState(0)'' and apply it to ''P32''. const uint8_t INPUT_PIN = 0; const uint8_t OUTPUT_PIN = 32; void setup() {} void loop() { const bool inputOn = digitalRead(INPUT_PIN) == HIGH; Iton(0, inputOn, 1000); // Update the timer in every loop before reading its state. const bool done = IgetState(0); // Read the output state of the timer with the same ID. digitalWrite(OUTPUT_PIN, done ? 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. * Call the timer with the same ID first. An ID that has not been created returns false. ===== Built-in Commands in the Same Category ===== * [[:en-us_commands:reference:igettime|IgetTime() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]