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:
XKPassword Super practical website for those who need to generate one or a list of passwords based on words (more secure).
SpeedOf.me Test the speed of your Internet connection
Elementary OS (Freya) Freya, a.k.a. Elementary OS, is my favorite Linux distribution. It looks slick and works great. Highly recommend it.
TinyMediaManager Small, but slick little application to manage your movies and movies meta-data (Windows, MacOS X and Linux!).
ViMediaManager ViMediaManager is a media manager for Mac OS X, allowing you to gather, store, and manage information, extra art, trailers and television tunes for your movie, television etc for use with for example XBMC.
Links Page These and more of our favorite links can be found on the Links Page.
MiniWOL2 MacOS (64 bits Apple Silicon)Date: 2023-08-01 - Size: 1.2 MBminiWol is a simple, but effective application to send Wake On LAN to network devices. This is the signed 64 bit MacOS ARM (Apple Silicon) version.
ConnectMeNow4-v4.0.10-macOS-arm64.dmgDate: 2023-07-07 - 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.10-macOS-x86-64.dmgDate: 2023-07-07 - 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.2.3-Windows-32bit-setup.exeDate: 2023-04-12 - 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.2.2-Linux-GTK-64bits.tar.gzDate: 2023-04-11 - 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.2.2-Linux-QT5-64bits.tar.gzDate: 2023-04-11 - 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.
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: