So first off, I know millis() exists. Just asking out of curiosity. Say you have a button you wanna check for during a delay.. Maybe a 10 second delay. So you make a for loop that checks for input and delays 1 ms... 10,000 times. What's bad about this?
int pin = 13;
bool button = false;
void setup()
{
pinMode(pin, INPUT);
}
void loop()
{
while(button == false) {
for(int i = 0; i<10000; i++) {
if(digitalRead(pin,HIGH){
button = true;
}
delay(1);
}
}
}
loop
. Your code becomes simpler, if you don't nest other waiting loops inside. Simpler is Better.