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:
Lubuntu A Ubuntu variant aimed at being small and fast. Love it!
Internet Archive: Wayback Machine Ever wondered what a current or disappeared website used to look like? Check it! Go back in time ...
ForkLift Great tool for FTP, SFTP, remote editing of text files (through SSH) and even a great Finder replacement - Not free, but keep an eye on special offerings (I got my copy for $5)
Leapfrog 3D printers Manufacturer of the great Creatr and Xeed 3D printers - Stunning customer service!!
Osceola, WI My other home-town ... love living there! Osceola rocks!
XKPassword Super practical website for those who need to generate one or a list of passwords based on words (more secure).
Links Page These and more of our favorite links can be found on the Links Page.
New Downloads
ConnectMeNow4-v4.0.18-macOS-x86-64.dmgDate: 2024-04-24 - Size: 3.5 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.
ConnectMeNow4-v4.0.18-macOS-arm64.dmgDate: 2024-04-24 - Size: 3 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).
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.
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.
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).