====== Itpl() ====== ''Itpl()''は(Pulse Timer)条件がONになった瞬間から設定時間の間trueを返します。 {{:ja-jp_commands:reference:itpl.svg?900|Itpl コマンドの動作フロー}} ''bool Itpl(uint8_t timer_id, bool state, unsigned long delayTime)'' ===== コマンド ===== ^ コマンド ^ 引数 ^ 戻り値 ^ 動作 ^ | ''Itpl(timer_id, state, delayTime)'' | ''uint8_t timer_id'' — タイマ番号。''0'' ~ ''255''の範囲で使用可能\\ ''bool state'' — タイマ入力状態\\ ''unsigned long delayTime'' — 設定時間。単位はms | ''bool'' | (Pulse Timer)条件がONになった瞬間から設定時間の間trueを返します。 | ===== 使用例 ===== MPINO-8A4R(T)-Sを選択した例です。入力''P0''と出力''P32''を使用し、''loop()''を止めずに毎回コマンドを呼び出します。 入力の立ち上がりで出力が1秒間ONになり、動作中の再入力で1秒を数え直します。 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); // 立ち上がりで1秒のパルスを作り、再入力時に時間を数え直します。 digitalWrite(OUTPUT_PIN, outputOn ? HIGH : LOW); } ===== 注意事項 ===== * 経過時間と入力OFFを処理するため、タイマコマンドを''loop()''で繰り返し呼び出します。 * 異なるタイマ動作で同じ''timer_id''を共有すると状態が混ざるため、別の番号を使用します。 ===== 同じカテゴリの内蔵コマンド ===== * [[:ja-jp_commands:reference:iton|Iton() 詳細説明を見る]] * [[:ja-jp_commands:reference:itof|Itof() 詳細説明を見る]] * [[:ja-jp_commands:reference:itmon|Itmon() 詳細説明を見る]] * [[:ja-jp_commands:reference:itmr|Itmr() 詳細説明を見る]] [[:ja-jp_commands:builtin|← 内蔵コマンド一覧]]