Page 1 of 1

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!

LED Effects - A cha...
Clear all

[Solved] LED Effects - A challenging 'Fire' effect problem

4 Posts
2 Users
0 Reactions
New Member
Joined: 3 years ago
Posts: 2
Topic starter  

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?

Any suggestions would be much appreciated!


Famed Member Admin
Joined: 11 years ago
Posts: 2724

Hi Mark,

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.

So basically like this:


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:

149, 148, ..., 3, 2, 1, 0  - Arduino - 0, 1, 2, 3, ..., 148, 149

So we have 300 LEDs, and I'd declare that as an additional value, something like:

#define ALL_LEDS 300

I also assume you declared the strips individually, something like this:

 FastLED.addLeds<WS2811, PIN1, GRB>(leds1, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.addLeds<WS2811, PIN2, GRB>(leds2, NUM_LEDS).setCorrection( TypicalLEDStrip );

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]) {
    } else {
  // 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] );


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.

This is the setPixel function originally:

void setPixel(int Pixel, byte red, byte green, byte blue) {
   // NeoPixel
   strip.setPixelColor(Pixel, strip.Color(red, green, blue));
   // FastLED
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;

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
Use Strip2, and LED = Pixel - NUM_LEDS

Since I assumed you're using FastLED, we could rewrite the setPixel function to this:

void setPixel(int Pixel, byte red, byte green, byte blue) {
 int newPixel;
 if(Pixel < NUM_LEDS) {
   leds1[(NUM_LEDS-1) - Pixel] = CRGB(red,green,blue);
 else {
   leds2[Pixel - NUM_LEDS] = CRGB(red,green,blue);


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.

New Member
Joined: 3 years ago
Posts: 2
Topic starter  

Hans - many thanks for the quick response!

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 😀 

Thanks again!

Famed Member Admin
Joined: 11 years ago
Posts: 2724

Awesome! Well, let me know if this works or if you run into other questions 😊