====== IgetCount() ====== ''IgetCount()'' returns the current value of the specified counter. {{:en-us_commands:reference:igetcount.svg?900|IgetCount command operation flow}} ''int32_t IgetCount(uint8_t counter_id)'' ===== Commands ===== ^ Command ^ Arguments ^ Return Value ^ Operation ^ | ''IgetCount(counter_id)'' | ''uint8_t counter_id'' — Counter number. Supports ''0'' ~ ''255'', the ''uint8_t'' range | ''int32_t'' | Returns the current value of the specified counter. | ===== Example ===== This example uses the P0 and P1 inputs on MPINO-8A4R(T)-S. const uint8_t COUNTER_ID = 3; const int32_t BATCH_SIZE = 100; void setup() { Serial.begin(115200); } void loop() { const bool itemSensor = digitalRead(0) == HIGH; const bool resetButton = digitalRead(1) == HIGH; Ictu(COUNTER_ID, itemSensor, resetButton, BATCH_SIZE); // Count rising input edges and return true when the preset is reached. const int32_t current = IgetCount(COUNTER_ID); // Return the current value of the specified counter. static int32_t previous = -1; if (current != previous) { previous = current; Serial.print(F("count=")); Serial.println(current); } } ===== 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:ictud|Ictud() 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]]