Good day can someone help me
i want to pause a arduino loop with a push button and then auto resume after a set delay
Good day can someone help me
i want to pause a arduino loop with a push button and then auto resume after a set delay
Yes....
Please read and use the topic "How to get the best out of this forum".
if (button_pressed == true) delay(set_delay);
Assuming you want an immediate interruption wherever you are within the loop(), you could use a blocking interrupt that would trigger upon detecting the button press and just stay stuck until you release the button.
depending on your Arduino you might have to deal with watchdog or the fact that millis() won't be maintained, but could work for your need.
if it's OK to let the loop finish it's current cycle and you press long enough on the button (set as INPUT_PULLUP in setup) then
void loop() {
while (digitalRead(stopButtonPin) == LOW) yield(); // block whilst the button is down
... here the rest of your code
}
code is running a roller. i want to feed a distance and then pause on a single button press and then resume automatically after a set time
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.