Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
While tinkering on something similar, I was able to change my code easily to support 3 colors, showing red, white and blue. You can select you own colors of course and the speed.
This sketch relies on FastLed. Set the proper NUM_LEDS and the proper PIN used on your Arduino.
Thank you for the compliment! Took me a second before I understood what you're asking (In think).
So you basically want to be able to define colors, and for each color the number of LEDs?
In that case, we'd better tart from scratch, as this sketch was not really intended to support this. We'd have to figure a way to capture this in a formula, so we can determine values for (in the original code) b1 and b2, and that based on the number of LEDs that color "segment" may have.
I'd probably go even one step further, and even use a way to shift all LEDs. If we'd go that route, we may even be able to use a predefined array of colors. Not sure how many LEDs you have in mind?
Hello @hans, thank you a lot for your reply! I'm sorry for the imprecise description of my project! But I think you got what I wanted to achieve. My goal is that I want to adjust the code so that each color is a segment of pixels and the number of pixels for each segment (color) is defined by a global variable. All colors together should always be 20 pixels. I hope you got a better understanding of what I am trying to do. I already tried to adjust the code by using an Array for the Pixels, but it was not working. Do you have any idea how I could do this?
Are you thinking of a fixed number of LEDs and colors, that just keep cycling? Meaning:
1. We set all LEDs to the initial colors we like to see. 2. We copy the color of the last LED (= LED NUM_LEDS-1). 3. We shift all LEDs one position (so the last one drops off). 4. We copy that last LED color from step 2, to the 1st LED (= LED 0).
If that would be the case, then it would be good to define an array with all the colors.
The simplest, but not very efficient way, would be:
Where "CRGB(r,g,b)" is a color of your choosing. Note: keep in mind that the LEDs count from 0 to NUM_LEDS-1. Note: Smarter ways would be if we can somehow calculate the colors with a formula, or when chunks repeating patterns can be copied.
Next we would want a loop that keeps repeating steps 2, 3 and 4.
Something like
CRGB LastLED;
...
LastLED = leds[NUM_LEDS-1];
...
Shifting can be done with a for-loop, or with the much faster memmove8 function, which looks like this:
Kubuntu Kubuntu is a Ubuntu variant that use KDE as it's desktop manager. Fast and well supported.
Media Player Classic My favorite media player for Windows - light weight and supports all common video formats.
Links Page These and more of our favorite links can be found on the Links Page.
New Downloads
RenameMyTVSeries-2.3.0-macOS-Universal.dmgDate: 2025-07-06 - Size: 98 MBRename My TV Series, for macOS (Universal binary for Apple Silicon ARM and Intel 64 bit), a tool to assist in renaming TV Show episode files. Static universal binary builds of ffmpeg and ffprobe are included.
RenameMyTVSeries-2.3.0-Windows-x64-setup.exeDate: 2025-07-06 - Size: 48.8 MBRename My TV Series, for Windows (Intel 64 bit), a tool to assist in renaming TV Show episode files. Static builds of ffmpeg and ffprobe are included.
RenameMyTVSeries-2.3.0-QT5-Linux-x64-static-ffmpeg.tar.xzDate: 2025-07-06 - Size: 78.3 MBRename My TV Series, for Linux (64 bit QT5), a tool to assist in renaming TV Show episode files. This bundle comews with rather large static builds of ffmpeg and ffprobe.
RenameMyTVSeries-2.3.0-QT5-Linux-x64-shared-ffmpeg.tar.xzDate: 2025-07-06 - Size: 1.9 MBRename My TV Series, for Linux (64 bit QT5), a tool to assist in renaming TV Show episode files. This bundle relies on ffmpeg and ffprobe shared libraries on your system.
RenameMyTVSeries-2.3.0-GTK-Linux-x64-static-ffmpeg.tar.xzDate: 2025-07-06 - Size: 78.3 MBRename My TV Series, for Linux (64 bit GTK), a tool to assist in renaming TV Show episode files. This bundle comes with (large) static builds of ffmpeg and ffprobe.
RenameMyTVSeries-2.3.0-GTK-Linux-x64-shared-ffmpeg.tar.xzDate: 2025-07-06 - Size: 1.9 MBRename My TV Series, for Linux (64 bit GTK), a tool to assist in renaming TV Show episode files. This bundle relies on ffmpeg and ffprobe shared libraries on your system.
Downloads Page Find these and more Downloads on the Downloads Page, where you will also find articles references, operating system requirements and categories.
Amazon Ads
Support us by doing your shopping at Amazon.com, either click the link, or click one of the links below …
You can also sponsor us through these Amazon offerings:
Please consider disabling your ad blocker for our website.We rely on these ads to be able to run our website.You can of course support us in other ways (see Support Us on the left).