Active waiting

I am new to Arduino programming but I have some experience with computer programming. I have always been told that ‘active waiting’ (waiting with looping on the execution of some code) is a bad practice, which can make the processor heat and possibly burn. However, most of the samples that I see for Arduino use active waiting: they iterate over and over again until some input signal is received. Is this practice acceptable for Arduino programming? Is the Arduino designed not to heat when active waiting is used?


The arduino processor normally runs at one constant speed determined by the frequency of it's oscillator (16Mhz for Arduino) no matter what code it's running and it's always running some code, there is no halt condition in normal conditions. A wait or delay loop is no difference then a calculation loop as far as power consumption goes.

The AVR chip does have some special sleep modes where the chip is put into a low speed/low power condition and waits for some kind of interrupt to 'wake-up'. But other then that it's just a constant speed device. Now a chips heat generation will be effected by how much current is being drawn by external components wired to it's output pins, so there is power/heat variation there.


patrickmarie84: (waiting with looping on the execution of some code) is a bad practice

It is only bad practice in that it makes it harder to do multiple things at once. Blinking an LED with a busy-waiting loop is easy. Blinking an LED whilst sending and receiving serial data would be harder since the busy-waiting loop keeps you from servicing the serial line in a timely manner.

On a microcontroller like the AVR, a certain amount of busy waiting is inevitable. Don't worry about it.

which can make the processor heat and possibly burn

Total tosh. Pay no attention.