Go Down

Topic: Loop delay needed? (Read 325 times) previous topic - next topic

Riccarr

Hello

Is there a need use a delay in the main LOOP function? The silly thought I have is that it will overheat the atmegs chip with continuous looping; but that is not true, right?

I understand wanting to use a loop if your maybe logging data or writing to serial monitor and you don't want a stream of data flying by. What if I my program logic is monitoring input pins, even shift register, and want to keep a constant watch on their states so that the program can do its logic based on their readings. I have no need to delay anything or slow it down so I don't need to insert delay, right?

PeterH


Is there a need use a delay in the main LOOP function?


No.
I only provide help via the forum - please do not contact me for private consultancy.

retrolefty

Waiting for our own PaulS to chime in that "delay() statements don't belong anywhere is a sketch, it is an evil function."  ;)

Lefty

retrolefty


Hello

Is there a need use a delay in the main LOOP function? The silly thought I have is that it will overheat the atmegs chip with continuous looping; but that is not true, right?

Correct. But keep in mind that the AVR chip in an arduino board is always running at 16Mhz flat out and is always executing instructions at the same clock speed, it never stops, so current consumption is not related to coding content directly, It can be consider for all practical purposes to draw a constant current, just what current flow might be flowing into or out of output pins driving external components and such might vary with your sketch commands.

I understand wanting to use a loop if your maybe logging data or writing to serial monitor and you don't want a stream of data flying by. What if I my program logic is monitoring input pins, even shift register, and want to keep a constant watch on their states so that the program can do its logic based on their readings. I have no need to delay anything or slow it down so I don't need to insert delay, right?

robtillaart

Quote
Is there a need use a delay in the main LOOP function?

no, delay() is a convenience function that helps most beginners to get things working but after some time the all go learn " blink without delay()" (google)

Quote
is always executing instructions at the same clock speed, it never stops,

Except when in sleep mode - see datasheet or google "Nick Gammon sleep arduino"
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up