User Tools

Site Tools


en-us_commands:ibounce

Differences

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

Link to this comparison view

Next revision
Previous revision
en-us_commands:ibounce [2026/09/07 21:52] – 만듦 - 바깥 편집 127.0.0.1en-us_commands:ibounce [2026/09/08 00:53] (current) – 바깥 편집 127.0.0.1
Line 16: Line 16:
 ===== Example ===== ===== Example =====
  
-The following example filters MPAINO's first digital input ''0'' for 50ms and passes it to the first digital output ''64''.+This example filters MPAINO digital input ''0'' for 50 ms, sends the stable state to digital output ''64'', and logs only state changes to the Serial Monitor.
  
 <code cpp> <code cpp>
 +const uint8_t INPUT_CHANNEL = 0;
 +const uint8_t OUTPUT_CHANNEL = 64;
 +
 +void setup() {
 +  Serial.begin(115200);
 +}
 +
 void loop() { void loop() {
-  // Return the retained value when input remains unchanged for 50ms+  const bool inputState = Ibounce(INPUT_CHANNEL, 50);  // Return the stable ON/OFF value after the input state remains unchanged for 50 ms
-  bool inputState = Ibounce(050); +  digitalWrite(OUTPUT_CHANNELinputState ? HIGH : LOW); 
-  digitalWrite(64, inputState);+ 
 +  static bool previousState = false; 
 +  if (inputState != previousState
 +    previousState = inputState; 
 +    Serial.println(inputState ? F("input ON") : F("input OFF")); 
 +  }
 } }
 </code> </code>
Line 33: Line 45:
   * ''pin'' must follow the input numbering of the product. MPINO uses product-specific Arduino digital input pin numbers; supported MPAINO products use logical input numbers starting at ''0''.   * ''pin'' must follow the input numbering of the product. MPINO uses product-specific Arduino digital input pin numbers; supported MPAINO products use logical input numbers starting at ''0''.
   * An invalid pin number returns ''false''.   * An invalid pin number returns ''false''.
 +
 +
 +===== Built-in Commands in the Same Category =====
 +
 +  * [[:en-us_commands:reference:idigitalread|IdigitalRead() View detailed description]]
 +  * [[:en-us_commands:reference:ibounceon|IbounceOn() View detailed description]]
 +  * [[:en-us_commands:reference:ibounceoff|IbounceOff() View detailed description]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/ibounce.1788785565.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki