Skip to main content
3 of 3
edited tags
VE7JRO
  • 2.5k
  • 19
  • 28
  • 31

Would an infinite loop inside loop() perform faster?

When you're writing a typical sketch, you usually rely on loop() being called repeatedly for as long as the Arduino is running. Moving in and out of the loop() function must introduce a small overhead though.

To avoid that, you could presumably create your own infinite loop, like this:

void loop()
{
    while (true)
    {
        // do stuff...
    }
}

Is that a viable way to improve performance? Will it cause other problems if loop() never returns?

Peter Bloomfield
  • 11k
  • 9
  • 48
  • 87