目次

IgetCount()

IgetCount()は指定したカウンタの現在値を返します。

IgetCount コマンドの動作フロー

int32_t IgetCount(uint8_t counter_id)

コマンド

コマンド 引数 戻り値 動作
IgetCount(counter_id) uint8_t counter_id — カウンタ番号。uint8_tの範囲のため0 ~ 255を使用可能 int32_t 指定したカウンタの現在値を返します。

使用例

MPINO-8A4R(T)-SのP0・P1入力を使用する例です。

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);  // 入力の立ち上がり回数を数え、設定値に達するとtrueを返します。
 
  const int32_t current = IgetCount(COUNTER_ID);  // 指定カウンタの現在値を返します。
  static int32_t previous = -1;
  if (current != previous) {
    previous = current;
    Serial.print(F("count="));
    Serial.println(current);
  }
}

注意事項

同じカテゴリの内蔵コマンド

← 内蔵コマンド一覧