Delay Function Alternatives

Hi, I noticed that most advance programmers tend to not use the delay function. If they don't use delay, what do they use to lets say delay the code for a hour?

See the BlinkWithoutDelay example.

Code based on millis().

See Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE

"Advanced" programmers simply do not delay. They "keep an eye" on the clock while going about all their business, and do each thing at the appointed time.

Quite a different concept, and the same as well-organised people do in day-to-day life. :sunglasses:

Except when it is the correct function to meet the requirements of the project

Hello
Technical spoken:
Using the delay() function is wasting of CPU time.

It is not wasting the time of the CPU if you don't want or need it to be doing anything else during the delay period

There is always an exception. :nerd_face:

You could be speaking about a lot of sketches we see :slight_smile:

delay(1)
count++

If count > 36000 × 8
Do that thing
Count=0

NOT RECOMENDED
Just a variation of delay()

I don't use this often. Just another tool.

Since i am currently watching soil moisture I can waste a lot of CPU time

Or watching paint dry? :rofl:

More like watching grass grow. :smiley:

you may have guessed that I am in New Jersey.

watching the leave change from green to orange, red and yellow, then to brown is fun for a few weeks,
then the really exciting bit is watching them fall to the ground ! now THAT is some FAST action there.