en-us_commands:reference:ictud
This is an old revision of the document!
Table of Contents
Ictud()
Ictud() handles increment and decrement inputs in one counter.
bool Ictud(uint8_t counter_id, bool CU, bool CD, bool RESET, bool LOAD, int32_t PV)
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
Ictud(counter_id, CU, CD, RESET, LOAD, PV) | uint8_t counter_id — Counter number. Supports 0 ~ 255, the uint8_t rangebool CUbool CDbool RESETbool LOADint32_t PV — Preset value | bool | Handles increment and decrement inputs in one counter. |
Example
const uint8_t COUNTER_ID = 2; const int32_t RACK_CAPACITY = 100; void setup() { Serial.begin(115200); } void loop() { const bool entered = IdigitalRead(0, 5); // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. const bool exited = IdigitalRead(1, 5); // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. const bool reset = IdigitalRead(2, 5); // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. const bool preset = IdigitalRead(3, 5); // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. const bool full = Ictud(COUNTER_ID, entered, exited, reset, preset, RACK_CAPACITY); // Process up and down inputs with one counter. digitalWrite(32, full ? HIGH : LOW); }
Precautions
- The previous fixed 0~31 restriction has been removed. However, the argument type is
uint8_t, so the maximum ID is255. - If insufficient memory prevents allocation of counter state, counter commands return
falseor0. - Once created, counter state is retained while the program runs.
en-us_commands/reference/ictud.1788791734.txt.gz · Last modified: by 127.0.0.1
