user61969: 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);

    }
  }
}


user10794: 
What's bad about this?

It looks a bit clunky but I suppose there is nothing particularly bad about it (apart from your typo of digitalWrite rather than digitalRead).
I would do it more like:
unsigned long now = millis ();
button = LOW;

while ((millis () - now < 10000) && (button == LOW))
  button = digitalRead (pin);


user60431: You can do this, for quite simple sketches. It starts to become ugly if you add more features and conditions.
Therefore, the "correctTM" (read: professional) way is to implement a state machine. See in the IDE the non-delay blink example.
const unsigned long DELAY_MS = 1000;

int pin = 13;

enum State {
    WAITING, WORKING,
};

State state;

unsigned long startTime;

void setup()
{
    pinMode(pin, INPUT);
    state = WAITING;
    startTime = millis();
}

void loop()
{
    switch (state) {
    case WAITING:
        // You can put both conditions in one "if" with an "||" operator.
        // But it will look less clear.
        if (millis() - startTime > DELAY_MS) {
            state = WORKING;
        } else if (digitalRead(pin)) {
            state = WORKING;
        }
        break;
    case WORKING:
        // anything to do after the delay or the button
        break;
    default:
        // any error handling you see fit
        break;
    }
}

The function loop() is designed to be called endlessly in repetition. Use this to your advantage.

61969: <p>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?</p>
<pre><code> int pin = 13;   
    bool button = false;        
    
    void setup()
    {
      pinMode(pin, INPUT);    
    }
    
    void loop()
    {

     while(button == false) {
     for(int i = 0; i&lt;10000; i++) {
     if(digitalRead(pin,HIGH){
     button = true;
}
     delay(1);

    }
  }
}
</code></pre>
 10794: <blockquote>
<p>What's bad about this?</p>
</blockquote>
<p>It looks a bit clunky but I suppose there is nothing particularly bad about it (apart from your typo of digitalWrite rather than digitalRead).</p>
<p>I would do it more like:</p>
<pre><code>unsigned long now = millis ();
button = LOW;

while ((millis () - now &lt; 10000) &amp;&amp; (button == LOW))
  button = digitalRead (pin);
</code></pre>
 60431: <p>You can do this, for quite simple sketches. It starts to become ugly if you add more features and conditions.</p>
<p>Therefore, the &quot;correct<sup>TM</sup>&quot; (read: <em>professional</em>) way is to implement a state machine. See in the IDE the non-delay blink example.</p>
<pre class="lang-cpp prettyprint-override"><code>const unsigned long DELAY_MS = 1000;

int pin = 13;

enum State {
    WAITING, WORKING,
};

State state;

unsigned long startTime;

void setup()
{
    pinMode(pin, INPUT);
    state = WAITING;
    startTime = millis();
}

void loop()
{
    switch (state) {
    case WAITING:
        // You can put both conditions in one &quot;if&quot; with an &quot;||&quot; operator.
        // But it will look less clear.
        if (millis() - startTime &gt; DELAY_MS) {
            state = WORKING;
        } else if (digitalRead(pin)) {
            state = WORKING;
        }
        break;
    case WORKING:
        // anything to do after the delay or the button
        break;
    default:
        // any error handling you see fit
        break;
    }
}
</code></pre>
<p>The function <code>loop()</code> is designed to be called endlessly in repetition. Use this to your advantage.</p>
