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 CDbool LOADint32_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); }
uint8_tのため、最大IDは255です。falseまたは0を返します。