en-us_commands:reference:idown
Table of Contents
Idown()
Idown() returns true only at the instant the input changes from ON to OFF.
bool Idown(uint8_t id, bool input)
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
Idown(id, input) | uint8_t idbool input | bool | Returns true only at the instant the input changes from ON to OFF. |
Example
const uint8_t COMMAND_INPUT = 0; const uint8_t MOTOR_OUTPUT = 32; void setup() { Serial.begin(115200); } void loop() { const bool input = IdigitalRead(COMMAND_INPUT, 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 started = Iup(0, input); // Return true only at the instant the input changes from OFF to ON. const bool stopped = Idown(0, input); // Return true only at the instant the input changes from ON to OFF. static bool run = false; Ialt(started, run); // Toggle the specified state ON/OFF at each rising input edge. digitalWrite(MOTOR_OUTPUT, run ? HIGH : LOW); if (started) Serial.println(F("motor started")); if (stopped) Serial.println(F("command released")); }
Precautions
Using the same id for different signals may mix their previous states. Do not set the minimum and maximum of the Iscale input range to the same value.
Built-in Commands in the Same Category
en-us_commands/reference/idown.txt · Last modified: by 127.0.0.1
