====== Ictud() ====== ''Ictud()'' handles increment and decrement inputs in one counter. {{:en-us_commands:reference:ictud.svg?900|Ictud command operation flow}} ''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'' range\\ ''bool CU''\\ ''bool CD''\\ ''bool RESET''\\ ''bool LOAD''\\ ''int32_t PV'' — Preset value | ''bool'' | Handles increment and decrement inputs in one counter. | ===== Example ===== This example uses the P0 through P3 inputs and the P32 output on MPINO-8A4R(T)-S. 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); // 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 is ''255''. * If insufficient memory prevents allocation of counter state, counter commands return ''false'' or ''0''. * Once created, counter state is retained while the program runs. ===== Built-in Commands in the Same Category ===== * [[:en-us_commands:reference:ictu|Ictu() View detailed description]] * [[:en-us_commands:reference:ictd|Ictd() View detailed description]] * [[:en-us_commands:reference:igetcount|IgetCount() View detailed description]] * [[:en-us_commands:reference:isetcount|IsetCount() View detailed description]] * [[:en-us_commands:reference:ictuddownstate|IctudDownState() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]