User Tools

Site Tools


en-us_commands:reference:isetcount

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en-us_commands:reference:isetcount [2026/09/07 23:35] – 바깥 편집 127.0.0.1en-us_commands:reference:isetcount [2026/09/08 00:53] (current) – 바깥 편집 127.0.0.1
Line 17: Line 17:
 <code cpp> <code cpp>
 const uint8_t COUNTER_ID = 4; const uint8_t COUNTER_ID = 4;
-const int32_t BATCH_SIZE 100;+const uint8_t PRESET_BUTTON_PIN = 0; 
 +const int32_t PRESET_COUNT 25;
  
 void setup() { void setup() {
   Serial.begin(115200);   Serial.begin(115200);
-  IsetCount(COUNTER_ID, 25);  // Change the specified counter's current value. 
 } }
  
 void loop() { 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 presetButton digitalRead(PRESET_BUTTON_PIN== HIGH
-  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. +  static bool previousButton false; 
-  const bool done = Ictu(COUNTER_ID, itemSensor, resetButton, BATCH_SIZE);  // Count rising input edges and return true when the preset is reached+ 
-  digitalWrite(32, done ? HIGH : LOW);+  if (presetButton && !previousButton) { 
 +    IsetCount(COUNTER_ID, PRESET_COUNT);  // Change the specified counter's current value
 +    Serial.println(F("counter preset to 25")); 
 +  } 
 +  previousButton = presetButton;
 } }
 </code> </code>
Line 37: Line 41:
   * If insufficient memory prevents allocation of counter state, counter commands return ''false'' or ''0''.   * If insufficient memory prevents allocation of counter state, counter commands return ''false'' or ''0''.
   * Once created, counter state is retained while the program runs.   * 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:igetcount|IgetCount() View detailed description]]
 +  * [[:en-us_commands:reference:ictuddownstate|IctudDownState() View detailed description]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/reference/isetcount.1788791735.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki