Skip to main content
added 82 characters in body
Source Link
chrisl
  • 16.5k
  • 2
  • 17
  • 27

// 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.

// 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.
Source Link

when i compile my code i get th is error stating "checkbutton" not declared in this scope

// 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.