# Is a timed 1 sec while() loop functionally equivalent to a delay(1000) ?

**URL:** <https://forum.arduino.cc/t/is-a-timed-1-sec-while-loop-functionally-equivalent-to-a-delay-1000/1300386>\
**Category:** Programming\
**Created:** [September 10, 2024, 6:48pm UTC](https://forum.arduino.cc/t/is-a-timed-1-sec-while-loop-functionally-equivalent-to-a-delay-1000/1300386 "2024-09-10T18:48:54Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![DaveX](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/davex/32/751443_2.png) [@DaveX](https://forum.arduino.cc/u/DaveX)\
**Post date:** [September 10, 2024, 7:00pm UTC](https://forum.arduino.cc/t/is-a-timed-1-sec-while-loop-functionally-equivalent-to-a-delay-1000/1300386/4 "2024-09-10T19:00:23Z")

</div>

They are functionally the same, and hobble your CPU for 99.9999% of the time.

The option [C] alternative that folks advocate for is that instead of spending 99.999% of the time watching the clock, write your code so that while it watches the clock, it can share the 99.999% of the processor with other tasks.

[C]

```arduino
void loop(){
  if(millis() - previousMillis >= LCD_DELAY){
     previousMillis = millis();
     writeNewMessage();
  }
  //... check 1000 other things and come back later..
}

```

See these:

> [@Best first 5 topics to read to reach Trust Level 1?](https://forum.arduino.cc/t/best-first-5-topics-to-read-to-reach-trust-level-1/1287592/1):
>
> - [Planning and Implementing an Arduino Program](https://forum.arduino.cc/t/planning-and-implementing-an-arduino-program/252364/2) by @Robin2-- A great way to plan your program to be flexible, easy to read, understand, maintain, and extend. ( Live Sim: [Lesson A](https://wokwi.com/projects/407398005837428737) ... [Lesson G](https://wokwi.com/projects/407397568486835201) )
> - [Demonstration code for several things at the same time](https://forum.arduino.cc/t/demonstration-code-for-several-things-at-the-same-time/217158) by @Robin2-- An example running a couple blinking LEDS, a button and two servos, all independently. ([Live Simulation](https://wokwi.com/projects/366664987128970241))
> - [Flashing multiple LEDs at the same time](https://forum.arduino.cc/t/flashing-multiple-leds-at-the-same-time/1065564) (thread by @PerryBebbington & others) -- several different styles of blinking leds. These are a collection of some natural extensions to the [Blink.ino](https://docs.arduino.cc/built-in-examples/basics/Blink/) and [BlinkWithoutDelay.ino](https://docs.arduino.cc/built-in-examples/digital/BlinkWithoutDelay/) . There's more than one way to do it. (And if you can blink LEDs, you can run a motor, trigger a device, or do many other tasks) Also, these multiple ways of doing the same thing task might help folks understand the important concepts behind the often-recommended BWOD example.

---

_[View the full topic](https://forum.arduino.cc/t/is-a-timed-1-sec-while-loop-functionally-equivalent-to-a-delay-1000/1300386)._
