How to make the LEDs come from both ends of the strip and meet in the middle or with a gap

Howdy, Im currently working on a project with some programable leds and have some code for a fire effect. I was wondering if someone could help me get it where the fire will start on the both edges of the strip and meet in the middle. Heres the code>>>

#include "FastLED.h"
#define NUM_LEDS 36 //36 for laptop
#define PIN 7
#define BRIGHTNESS 200
bool gReverseDirection = false;
CRGBPalette16 gPal;

void setup(){
FastLED.setBrightness( BRIGHTNESS );
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );

// This first palette is the basic 'black body radiation' colors,
// which run from black to red to bright yellow to white.
gPal = HeatColors_p;

void loop(){
// Add entropy to random number generator; we use a lot of it.
random16_add_entropy( random());

// Fourth, the most sophisticated: this one sets up a new palette every
// time through the loop, based on a hue that changes every time.
// The palette is a gradient from black, to a dark color based on the hue,
// to a light color based on the hue, to white
Fire2012WithPalette(); // run simulation frame, using palette colors; // display this frame
FastLED.delay(1000 / FRAMES_PER_SECOND);

// Fire2012 by Mark Kriegsman, July 2012
// as part of "Five Elements" shown here: "Five Elements" light sculpture (2nd installation) - YouTube
// This basic one-dimensional 'fire' simulation works roughly as follows:
// There's a underlying array of 'heat' cells, that model the temperature
// at each point along the line. Every cycle through the simulation,
// four steps are performed:
// 1) All cells cool down a little bit, losing heat to the air
// 2) The heat from each cell drifts 'up' and diffuses a little
// 3) Sometimes randomly new 'sparks' of heat are added at the bottom
// 4) The heat from each cell is rendered as a color into the leds array
// The heat-to-color mapping uses a black-body radiation approximation.
// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
// This simulation scales it self a bit depending on NUM_LEDS; it should look
// "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
// I recommend running this simulation at anywhere from 30-100 frames per second,
// meaning an interframe delay of about 10-35 milliseconds.
// Looks best on a high-density LED setup (60+ pixels/meter).
// There are two main parameters you can play with to control the look and
// feel of your fire: COOLING (used in step 1 above), and SPARKING (used
// in step 3 above).
// COOLING: How much does the air cool as it rises?
// Less cooling = taller flames. More cooling = shorter flames.
// Default 55, suggested range 20-100
#define COOLING 70

// SPARKING: What chance (out of 255) is there that a new spark will be lit?
// Higher chance = more roaring fire. Lower chance = more flickery fire.
// Default 120, suggested range 50-200.
#define SPARKING 70

void Fire2012WithPalette()
// Array of temperature readings at each simulation cell
static uint8_t heat[NUM_LEDS];

// Step 1. Cool down every cell a little
for( int i = 0; i < halfway; i++) {
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / halfway) + 2));

// Step 2.  Heat from each cell drifts 'up' and diffuses a little
for( int k= halfway - 1; k >= 2; k--) {
  heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;

// Step 3.  Randomly ignite new 'sparks' of heat near the bottom
if( random8() < SPARKING ) {
  int y = random8(7);
  heat[y] = qadd8( heat[y], random8(160,255) );

// Step 4.  Map from heat cells to LED colors
for( int j = 0; j < halfway; j++) {
  // Scale the heat value from 0-255 down to 0-240
  // for best results with color palettes.
  uint8_t colorindex = scale8( heat[j], 240);
  CRGB color = ColorFromPalette( gPal, colorindex);
  int pixelnumber;
  if( gReverseDirection ) {
    pixelnumber = (NUM_LEDS-1) - j;
  } else {
    pixelnumber = j;
  leds[pixelnumber] = color;


If they are programmable, arent you able to get or control each one individually? If so then can you try your routine for a set of them, and then run the same routine for the other set starting at the last led and working backwards to give you the affect you are wanting to get?

I only worked with these types of LEDs once and it was a small set and i was only playing around with triggering each led when i wanted..

I found this site that has example of handling each one individually;

If you scroll down to the section for the second example, there are 2 for loops, you can take that logic and try with yours..

Posted incorrectly, so difficult to read and possibly corrupted by the forum software. Please read the forum guide to find out how to post code here, then edit your post above and correct it.

What does it do now?

Pseudo code

for (int led = 0; led < 18; led++)
  write value to LEDS[led]
  write value to LEDS[35 - led]

This will write to a pair of LEDs each time through the for loop
0, 35
1, 34
2, 33
and so on

The code posted must be incomplete and could not even compile. "halfway" is used in 4 places but never defined.

Suggest we avoid wasting time on this topic until @Quintanschank has sorted out their original post.

Always a good idea. :grin:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.