# Run 2 LED animations independently

**URL:** <https://forum.arduino.cc/t/run-2-led-animations-independently/1183262>\
**Category:** Programming\
**Created:** [October 28, 2023, 6:42pm UTC](https://forum.arduino.cc/t/run-2-led-animations-independently/1183262 "2023-10-28T18:42:46Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [October 28, 2023, 7:04pm UTC](https://forum.arduino.cc/t/run-2-led-animations-independently/1183262/3 "2023-10-28T19:04:26Z")

</div>

Hi @trebeck

welcome to the arduino-forum.  
Well done posting code as a code-section in your very first posting.

You are asking for a medium advanced functionality that requires medium advanced knoweldge about programming.

It will need a medium time to learn these medium advanced programming.

You have two a sequences that should proceed from step to step each in their own speed.

This means both sequences must advance from step to step in parallel.  
As user @UKHeliBob mentioned parallel code-execution requires non-blocking timing as a must.  
There is no other way to do it.

As your LEDs shall not only blink but they shall be switched on/off in a more complex pattern  
this can be done using a coding technique called state-machine.

Both are medium advanced programming-techniques and this is what you have to learn to be able to apply it to your code.

So here is a tutorial that explains the basic principle of non-blocking timing

> [@Example-code for timing based on millis() easier to understand through the use of example-numbers / avoiding delay()](https://forum.arduino.cc/t/example-code-for-timing-based-on-millis-easier-to-understand-through-the-use-of-example-numbers-avoiding-delay/974017/1):
>
> non-blocking timing. Execute code only from time to time. There are a lot of different ways to learn programming. This thread wants to add another approach that is different to the yet existing ones. UPDATE 06.01.2023 if you are mainly interested in applying non-blocking timing you can do a quick read of this short tutorial / demonstration If you are intersted in understanding the details how it works go on reading here. I use an everyday analogon in this post to explain the basic principle …

and here is a tutorial that explains the basic principle of state-machines

> [@A Demo-Code explaining the switch-case state-machine and how to do things (almost) in parallel](https://forum.arduino.cc/t/a-demo-code-explaining-the-switch-case-state-machine-and-how-to-do-things-almost-in-parallel/888172/1):
>
> Hi everybody, if you look at the end of this first posting you see a list of links that show where this tutorial was used as a link. Go through this list to find additional information on how to apply this code This democode requires only the pure microcontroller without any hardware. You just open the serial monitor to watch the behaviour of the code. From time to time I enjoy writing demo-codes that want to explain programming-functionalities. There are a lot of different approachs to expl…

As already said: it will take some time to learn this. It is not done in 10 minutes.

best regards Stefan

---

_[View the full topic](https://forum.arduino.cc/t/run-2-led-animations-independently/1183262)._
