Change request example code "Blink Without Delay"

Because your sugesstion has a kind of a jitter of reading millis() depending on loop execution time.

The Blink Without Delay code does have "jitter" (I prefer to call it "drift") but the change suggested by PaulS eliminates it.

This should show a row of zeros, if the code is fine.

I have the PaulS code running now and it returns a row of zeros...

const unsigned long interval = 1000;

unsigned long previousMillis;
unsigned long delta;


void setup( void )
{
  Serial.begin( 9600 );
  pinMode( 6, OUTPUT );
  digitalWrite( 6, LOW );
  delay( 3000 );
  digitalWrite( 6, HIGH );
  previousMillis = millis();
}

void loop( void )
{
  unsigned long currentMillis = millis();
  
  if( currentMillis - previousMillis >= interval ) 
  {
    delta = currentMillis - previousMillis - interval;

    if ( delta != 0 )
    {
      digitalWrite( 6, LOW );
      Serial.println( delta );
    }
    previousMillis = currentMillis;
  }
  
  if ( Serial.available() )
  {
    while ( Serial.available() )
    {
      Serial.read();
    }
    digitalWrite( 6, HIGH );
  }
}

The difference between your code and the code suggested by PaulS is how overruns are handled. Your code will run twice in quick succession (number of runs over a given time span is preserved). The code from PaulS skips overruns (delay between runs is preserved). There is nothing wrong with either version. It's simply a matter of choosing which is appropriate for the application.