I need to run two FastLED controllers in parallel so that both LED strings display simultaneously with no delay between them. To my thinking, the only way to accomplish this is using both cores of the ESP32, wherein, each core effectively contains an independent LED controller.
However, as best as I can determine, the only place to add #include “FastLED.h” is at the very beginning of the program. I tried placing the #include in the beginning of the Taskcode for each core… but this results in a compiler error. With the #include at the beginning of the program, I believe the FastLED code for the controllers will only run in the main core…even if the second core calls a FastLED function.
This means I will not achieve two independent LED controllers…but rather one controller will need to finish running before the other can start (since the FastLED code is in only the main core).
I’m looking for a solution to this issue. I’m using the Arduino IDE. Your help is most appreciated.
I’m sorry for the delay in my response.
I think this section of the FastLED documentation describes what you want to achieve: https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples
Take a look at the Mirroring strips section: https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples#mirroring-strips
It shows how you can get the exact same effect on several strips at the same time (without the need to use dual core).
Let me know if this works for you or if you need further help.
Hi Sara. Thank you for your answer.
You are correct that mirroring strips will achieve the parallel update effect I desire. I was able to confirm this with an oscilloscope. Unfortunately, my application is a bit more complex.
I’m driving two WS2811 strings.
In all cases, both strings need to be driven nearly simultaneously. The LED strings are 484 pixels long.
The update/frame rate of the LEDs is directly proportional to the number of LEDs in the string (since the data is shifted through all the LEDs in a serial fashion).
My application requires that I support two update rates …. FAST and SLOW (note: I update both strings either FAST or SLOW…
I’m not trying to update one LED string FAST and one LED string slow at the same time.) .
In order to achieve the FAST rate, I need to reduce the number of LEDs to 22 for both strings. The FastLED library allows you to do this by defining two different controllers…with each controller having a different number of LEDs.
Thus I can have two FAST controllers and two LOW controller (each controller going to a different pin and LED string..I handle the pin MUXing separately when switching between FAST and SLOW).
However, The FastLED library does not allow you to output both controllers simultaneously. For controllers the syntax is:
This means that first controller 0 updates and shows it’s LEDs, then controller 1 updates and shows it’s LEDs….
in any case the update isn’t simultaneous for both controllers.
The mirroring technique does update both LED strings simultaneously because both strings are updated with a single FastLED.show()…
but in this case both strings are updated at the rate of the longest defined string of LEDs.
If the FastLED library allowed me to dynamically change the number of LEDs in the string I achieve all that I want (FAST and SLOW LEDs)….but as best as I can tell….you can’t dynamically change the number of LEDs in a string.
You can choose to not light a portion of the string… but the whole 484 pixels
will still update.
Only by re-defining the 484 pixel string to 22 pixels (for FAST updates) and from 22 to 484 (for SLOW updates) can I get the update rate and number of LEDs lit, that I require.
It is possible to achieve all that I desire with two separate Arduino boards simultaneously running the same code and each board driving its own LED string.
However, I would really like to simplify my design and use a single Arduino board.
I was hoping that the dual cores of the ESP32 would allow me to achieve my goals, but at this point I don’t see how?
Any further suggestions you might have are greatly appreciated. Thank you.
I understand your problem. It is a very specify situation and I’m not that familiar with the library to help you in such a specific project.
You can use two Arduino to run the same code. If you want to run the code simultaneously, you need something to synchronize the Arduino boards – they need to reset at the same time.
You can see some suggestions here: https://www.quora.com/How-can-I-start-multiple-Arduinos-individually-at-the-same-time-I-need-to-synchronize-multiple-Arduino-programs-that-don%E2%80%99t-have-the-same-power-source-and-cannot-communicate-with-each-other
But I don’t think it is that “simple” to achieve that – how well they will synchronize…
If you use ESP32 dual core, you can create two tasks that run the same code but output on a different pin, but I don’t know if they will run synchronized and how “easy” it is to do that.