Skip to main content
Arduino

Return to Revisions

2 of 3
address updated question
Edgar Bonet
  • 45.1k
  • 4
  • 42
  • 81

It depends on what your processor is doing while it has no real work to do:

  • If you put it to sleep, then yes, using floats will keep the CPU awake for a longer time and burn more energy.
  • If you are instead doing busy-waits (e.g. with delay()) it should make no difference, since the CPU is busy 100% of the time anyway.

Update: According to your update, it seems your program never sleeps. Then I would expect no substantial difference in power consumption between using floats or ints. As Majenko said, there can theoretically be some small difference depending on the number of transistor transitions involved in each instruction (and, I would add, the capacitive loading of the involved transistors), but I do not expect this to be very significant.

If you are really concerned about the consumption of your Arduino, I would suggest you use it only for prototyping, then move your code to a bare ATmega (or maybe even an ATtiny) chip. Also, add at least one call to sleep_mode() inside your main loop. Each such call will put your CPU to sleep until the next timer interrupt, which typically happens every 1024 μs. There is a lot more to say about power savings, see for example this excellent writeup by Nick Gammon.

Edgar Bonet
  • 45.1k
  • 4
  • 42
  • 81

AltStyle によって変換されたページ (->オリジナル) /