Pages: [1]   Go Down
Author Topic: Loop delay needed?  (Read 278 times)
0 Members and 1 Guest are viewing this topic.
Portland, Oregon, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12549
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

No.
Logged

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Lefty
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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"
Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: