// After 2 seconds have passed, stop ignoring the button. // If the button is pressed, call the checkbutton function. if (millis() > ignore && digitalRead(0) == LOW) { checkbutton(); } } // This function waits for the button to be released, // then waits for it to be pressed to start the next run. void checkbutton(){ delay (50); // Button pressed, debounce. while (digitalRead(0) == LOW) // While button is pressed, {} // do nothing while waiting. delay (50); // Button pressed, debounce. while (digitalRead(0) == HIGH)// While button is released, {} // do nothing while waiting.
ignore = 2000 + millis(); // Set the now ignore time, } // and return to the main loop.
// After 2 seconds have passed, stop ignoring the button.
// If the button is pressed, call the checkbutton function.
if (millis() > ignore && digitalRead(0) == LOW)
{
checkbutton();
}
}
// This function waits for the button to be released,
// then waits for it to be pressed to start the next run.
void checkbutton(){
delay (50); // Button pressed, debounce.
while (digitalRead(0) == LOW) // While button is pressed,
{} // do nothing while waiting.
delay (50); // Button pressed, debounce.
while (digitalRead(0) == HIGH)// While button is released,
{} // do nothing while waiting.
ignore = 2000 + millis(); // Set the now ignore time,
} // and return to the main loop.