User Tools

Site Tools


en-us_commands:reference:ictu

This is an old revision of the document!


Table of Contents

Ictu()

Ictu() counts input rising edges and returns true when the preset value is reached.

Ictu command operation flow

bool Ictu(uint8_t counter_id, bool CU, bool RESET, int32_t PV)

Commands

Command Arguments Return Value Operation
Ictu(counter_id, CU, RESET, PV) uint8_t counter_id — Counter number. Supports 0 ~ 255, the uint8_t range
bool CU
bool RESET
int32_t PV — Preset value
bool Counts input rising edges and returns true when the preset value is reached.

Example

const uint8_t COUNTER_ID = 0;
const int32_t BOX_CAPACITY = 20;
 
void setup() {
  Serial.begin(115200);
}
 
void loop() {
  const bool itemSensor = 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 resetButton = 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 boxFull = Ictu(COUNTER_ID, itemSensor, resetButton, BOX_CAPACITY);  // Count rising input edges and return true when the preset is reached.
  digitalWrite(32, boxFull ? 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 Command List

en-us_commands/reference/ictu.1788791734.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki