# How to make a loop run for a specific time then switch to another loop and then back and so on

**URL:** <https://forum.arduino.cc/t/how-to-make-a-loop-run-for-a-specific-time-then-switch-to-another-loop-and-then-back-and-so-on/1319925>\
**Category:** Programming\
**Created:** [November 8, 2024, 1:38pm UTC](https://forum.arduino.cc/t/how-to-make-a-loop-run-for-a-specific-time-then-switch-to-another-loop-and-then-back-and-so-on/1319925 "2024-11-08T13:38:48Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [November 8, 2024, 2:43pm UTC](https://forum.arduino.cc/t/how-to-make-a-loop-run-for-a-specific-time-then-switch-to-another-loop-and-then-back-and-so-on/1319925/3 "2024-11-08T14:43:03Z")

</div>

in the more general case, you might benefit from studying state machines.

Here is a small introduction to the topic: [Yet another Finite State Machine introduction](https://forum.arduino.cc/t/yet-another-finite-state-machine-introduction/1198997)

and you should look at dealing with millis() if you don't want to block your code. See

- [Using millis() for timing. A beginners guide](https://forum.arduino.cc/index.php?topic=503368.0)
- [Several things at the same time](https://forum.arduino.cc/index.php?topic=223286.0)
- [Flashing multiple LEDs at the same time](https://forum.arduino.cc/t/flashing-multiple-leds-at-the-same-time/1065564)

---

_[View the full topic](https://forum.arduino.cc/t/how-to-make-a-loop-run-for-a-specific-time-then-switch-to-another-loop-and-then-back-and-so-on/1319925)._
