en-us_commands:reference:isetcount
Table of Contents
IsetCount()
IsetCount() changes the current value of the specified counter.
void IsetCount(uint8_t counter_id, int32_t value)
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
IsetCount(counter_id, value) | uint8_t counter_id — Counter number. Supports 0 ~ 255, the uint8_t rangeint32_t value | void | Changes the current value of the specified counter. |
Example
const uint8_t COUNTER_ID = 4; const uint8_t PRESET_BUTTON_PIN = 0; const int32_t PRESET_COUNT = 25; void setup() { Serial.begin(115200); } void loop() { const bool presetButton = digitalRead(PRESET_BUTTON_PIN) == HIGH; static bool previousButton = false; if (presetButton && !previousButton) { IsetCount(COUNTER_ID, PRESET_COUNT); // Change the specified counter's current value. Serial.println(F("counter preset to 25")); } previousButton = presetButton; }
Precautions
- The previous fixed 0~31 restriction has been removed. However, the argument type is
uint8_t, so the maximum ID is255. - If insufficient memory prevents allocation of counter state, counter commands return
falseor0. - Once created, counter state is retained while the program runs.
Built-in Commands in the Same Category
en-us_commands/reference/isetcount.txt · Last modified: by 127.0.0.1
