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!
Hi - I’m hoping someone can give me a steer on how to approach modifying Hans' excellent ‘fire’ sketch for a stage prop I’m putting together. (Now hopefully posted in the right place!)
Put simply, I have two 150 LED strips laid end to end with the Arduino in-between the two strips. Each strip is connected to a different data output on the Arduino.
I need to make the fire start at the far left of the first strip (i.e. LED 150), move to the right (to LED 1) then continue on to the second strip (LED 1) finishing at the far right of this strip (LED 150) making a combined 300 LED strip.
I have completed a few large Arduino projects and think I understand how most of the code in the sketch works, but I am struggling to see how I can get the ‘fire’ to pass to a separate instance of FastLED for the second strip. It may be that there are better ways to address this?
So, if I understand this right, you'd like to use all 300 LEDs for the "fire", as in: one flame over all 300 LEDs?
If so, then really the easiest option is to connect both strips instead of trying to control 2 strips. So let's say we connect strip2 at the end of strip1, then you only have to connect +5V, GND and D0 (to Din of strip 2) from Strip1 to Strip2. Next change NUM_LEDS in your code to 300 and you're good to go.
Tip: if the brightness of the last LEDs is not so great, then you may need to run an extra +5V and GND wire from your power supply. This can be connected where you link the two strips, or at the end of Strip 2. I've noticed once where white light at the end (also 300 LEDs) started becoming more yellowish. Connecting the power supply also to the end of the strip made that go away. Since you're using the fire effect though, you may not need this.
If linking the two strips is not an option, then consider this;
Normally the LED closest to your Arduino would be LED 1. So simplified you're looking at this:
And you want the fire to start on the left with #149 and end on the right with #149. I hope I understood that correctly. 😉
Looking at the Fire Code, I'd first replace all occurrences of NUM_LEDS with the newly define ALL_LEDS, so that the effect assumes 300 LEDs to work with.
void Fire(int Cooling, int Sparking, int SpeedDelay) {
static byte heat[ALL_LEDS];
int cooldown;
// Step 1. Cool down every cell a little
for( int i = 0; i < ALL_LEDS; i++) {
cooldown = random(0, ((Cooling * 10) / ALL_LEDS) + 2);
if(cooldown>heat[i]) {
heat[i]=0;
} else {
heat[i]=heat[i]-cooldown;
}
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for( int k= ALL_LEDS - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
}
// Step 3. Randomly ignite new 'sparks' near the bottom
if( random(255) < Sparking ) {
int y = random(7);
heat[y] = heat[y] + random(160,255);
//heat[y] = random(160,255);
}
// Step 4. Convert heat to LED colors
for( int j = 0; j < ALL_LEDS; j++) {
setPixelHeatColor(j, heat[j] );
}
showStrip();
delay(SpeedDelay);
}
You'll see that in this function, none of the leds are being set yet. This is done in the setPixelHeatColor function where setPixel() is being called. So in setPixel() we can do some magic to pick the right LEDs.
So if the function want to set the first LED, we need to use strip1 LED 149. (LEDs start counting with zero since "leds" is an array of 150 elements, where 149 is the last one) I hope I don't screw up the math here ... but in essence we want this:
LED 0 -> Use strip 1, LED 149 (= NUM_LEDS-1 - Pixel = 150-1 - 0 = 149) LED 149 -> Use strip 1, LED 0 (= NUM_LEDS-1 - Pixel = 150-1 - 149 = 0) LED 150 -> Use strip 2, LED 0 (= Pixel - NUM_LEDS = 150 - 150 = 0) LED 299 -> Use Strip 2, LED 149 (= Pixel - NUM_LEDS = 299 - 150 = 149)
Which we can do in the setPixel function, something like this (pseudo code):
if Pixel<150 then Use Strip1, and LED = (NUM_LEDS-1) - Pixel else Use Strip2, and LED = Pixel - NUM_LEDS
Since I assumed you're using FastLED, we could rewrite the setPixel function to this:
Now keep in mind; I have not tested this code, and I do screw up every now and then when it comes to counting and array's. I'm pretty sure though this will be close to what you're looking for.
I do need to have the Arduino in the middle as I simplified the question a little as the design actually calls for three LED strips (although two mirror each other). Your proposed solution is very elegant and should be just what I need.
I'm still learning a lot from your other examples 😀
VueScan Ultimate scanning tool for Windows, Linux, and macOS, supporting pretty much any scanner, even those no longer supported by your OS. (no scanner drivers needed!)
7-Zip One of the best, free, and most efficient Windows archive and unarchive utilties around. Support quite a few formats as well.
Security Awareness Tip of the Day Great resource to make you online-life more secure - definitely some great tips here and a recommended read.
GTMetrix Awesome tool to analyze the speed of your website!
SpeedTest.net Test the speed of your Internet connection (requires Flash!!!)
RegExr Awesome website to play and experiment with regular expression!
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).