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.
LastLED = leds[NUM_LEDS-1];
Shifting can be done with a for-loop, or with the much faster memmove8 function, which looks like this:
GTMetrix Awesome tool to analyze the speed of your website!
Frizting Free tool to design schematics and PCB's - they even offer a very affordable PCB production service.
Links Page These and more of our favorite links can be found on the Links Page.
ConnectMeNow4-v4.0.8-macOS-arm64.dmgDate: 2023-03-18 - Size: 2.6 MBVersion 4 of ConnectMeNow - A tool for more convenient mounting of network shares under macOS. This is the Apple Silicon version (not suitable for Intel).
ConnectMeNow4-v4.0.8-macOS-x86-64.dmgDate: 2023-03-15 - Size: 3 MBVersion 4 of ConnectMeNow - A tool for more convenient mounting of network shares under macOS. This is the Intel version which works on Intel and Apple Silicon Macs.
MovieScanner2-2.1.3-Windows-32bit-setup.exeDate: 2023-03-09 - Size: 18.6 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 32 bit Windows version.
MovieScanner2-2.1.3-Linux-QT5-64bits.tar.gzDate: 2023-03-08 - Size: 29.1 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 64 bit Linux version for QT5.
MovieScanner2-2.1.3-Linux-GTK-64bits.tar.gzDate: 2023-03-08 - Size: 29.2 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 64 bit Linux version for GTK.
MovieScanner2-2.1.3-macOS-64bit.dmgDate: 2023-03-08 - Size: 26.3 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 64 bit macOS version.
Downloads Page Find these and more Downloads on the Downloads Page, where you will also find articles references, operating system requirements and categories.
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: