Yes, what Armor said. millis() is the best way to handle this, and make sure you structure it exactly like that:
if (millis() - lastTime >= interval)
This is necessary to make sure millis rollover does not cause problems:
Yes, what Armor said. millis() is the best way to handle this, and make sure you structure it exactly like that:
if (millis() - lastTime >= interval)
This is necessary to make sure millis rollover does not cause problems: