IgetCount() returns the current value of the specified counter.
int32_t IgetCount(uint8_t counter_id)
| 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. |
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); } }
uint8_t, so the maximum ID is 255.false or 0.