====== Ictd() ====== ''Ictd()''は設定値を読み込んだ後、入力の立ち上がりごとに現在値を減らします。 {{:ja-jp_commands:reference:ictd.svg?900|Ictd コマンドの動作フロー}} ''bool Ictd(uint8_t counter_id, bool CD, bool LOAD, int32_t PV)'' ===== コマンド ===== ^ コマンド ^ 引数 ^ 戻り値 ^ 動作 ^ | ''Ictd(counter_id, CD, LOAD, PV)'' | ''uint8_t counter_id'' — カウンタ番号。''uint8_t''の範囲のため''0'' ~ ''255''を使用可能\\ ''bool CD''\\ ''bool LOAD''\\ ''int32_t PV'' — 設定値 | ''bool'' | 設定値を読み込んだ後、入力の立ち上がりごとに現在値を減らします。 | ===== 使用例 ===== MPINO-8A4R(T)-SのP0・P1入力とP32出力を使用する例です。 const uint8_t COUNTER_ID = 1; const int32_t START_QUANTITY = 50; void setup() { Serial.begin(115200); } void loop() { const bool shipped = digitalRead(0) == HIGH; const bool loadQuantity = digitalRead(1) == HIGH; const bool empty = Ictd(COUNTER_ID, shipped, loadQuantity, START_QUANTITY); // 設定値をロード後、入力の立ち上がりごとに現在値を減算します。 digitalWrite(32, empty ? HIGH : LOW); } ===== 注意事項 ===== * 従来の0~31固定制限は削除されました。ただし引数型が''uint8_t''のため、最大IDは''255''です。 * メモリ不足でカウンタ状態を確保できない場合、カウンタコマンドは''false''または''0''を返します。 * 一度作成したカウンタ状態はプログラム実行中保持されます。 ===== 同じカテゴリの内蔵コマンド ===== * [[:ja-jp_commands:reference:ictu|Ictu() 詳細説明を見る]] * [[:ja-jp_commands:reference:ictud|Ictud() 詳細説明を見る]] * [[:ja-jp_commands:reference:igetcount|IgetCount() 詳細説明を見る]] * [[:ja-jp_commands:reference:isetcount|IsetCount() 詳細説明を見る]] * [[:ja-jp_commands:reference:ictuddownstate|IctudDownState() 詳細説明を見る]] [[:ja-jp_commands:builtin|← 内蔵コマンド一覧]]