Ictud()は増加入力と減少入力を1つのカウンタで処理します。
bool Ictud(uint8_t counter_id, bool CU, bool CD, bool RESET, bool LOAD, int32_t PV)
| コマンド | 引数 | 戻り値 | 動作 |
|---|---|---|---|
Ictud(counter_id, CU, CD, RESET, LOAD, PV) | uint8_t counter_id — カウンタ番号。uint8_tの範囲のため0 ~ 255を使用可能bool CUbool CDbool RESETbool LOADint32_t PV — 設定値 | bool | 増加入力と減少入力を1つのカウンタで処理します。 |
MPINO-8A4R(T)-SのP0~P3入力とP32出力を使用する例です。
const uint8_t COUNTER_ID = 2; const int32_t RACK_CAPACITY = 100; void setup() { Serial.begin(115200); } void loop() { const bool entered = digitalRead(0) == HIGH; const bool exited = digitalRead(1) == HIGH; const bool reset = digitalRead(2) == HIGH; const bool preset = digitalRead(3) == HIGH; const bool full = Ictud(COUNTER_ID, entered, exited, reset, preset, RACK_CAPACITY); // 加算入力と減算入力を1つのカウンタで処理します。 digitalWrite(32, full ? HIGH : LOW); }
uint8_tのため、最大IDは255です。falseまたは0を返します。