Group LEDs with FastLED?

Is it possible to group a series of LEDs permanently?
I can't quite describe the idea, but that's basically it in the images:


^ This would be the LED strip, the yellow dots are the pixels and the blue is the wires themselves as to how they will circle.

^ And this is what I want to accomplish, a full rainbow in flow passing over.
(this last image is an animated gif to see the effect)

If I don't control this in a grouped way, it will make the rainbow look like a snake, and I want the flow to be aligned laterally...
So, the first 10 is individual pixels, but the next 11 I want grouped together so that they always have the same color when use effects like rainbow flow.

(I can do this with the LedEdit-K software because it has a layout area, it is for programming modules like SP108E, but I wanted to do it with Arduino Mega.)

Can you help guys? :smiley:

Yes, just create arrays of numbers which represent the led number.

Ex if you had 4 groups of 20

Group1[0]=0;
..
Group1[19]=19;
Group2[0]=20;
...
Group4[19]=79;

#define Group4NUMLEDS 20

for(i=0, i<Group4NUMLEDS, i++){
FastLED[group4[i]].setHSV(255,255,255);
}
  
group4[i] where i is 19 would be the same as

FastLED[79]

Some of the syntax might be incorrect but that gives you a basic idea. At least that is how I did it but maybe there are easier ways.

Qdeathstar:
Yes, just create arrays of numbers which represent the led number.

Ex if you had 4 groups of 20

Group1[0]=0;

..
Group1[19]=19;
Group2[0]=20;
...
Group4[19]=79;

#define Group4NUMLEDS 20

for(i=0, i<Group4NUMLEDS, i++){
FastLED[group4[i]].setHSV(255,255,255);
}
 
group4[i] where i is 19 would be the same as

FastLED[79]




Some of the syntax might be incorrect but that gives you a basic idea. At least that is how I did it but maybe there are easier ways.

Like this?
(please, correct the sintax if error)

Group1[0]=0;
Group2[1]=1;
Group3[2]=2;
Group4[3]=3;
Group5[4]=4;
Group6[5]=5;
Group7[6]=6;
Group8[7]=7;
Group9[8]=8;
Group10[9]=9;
Group11[10]=10;
Group12[11]=11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21;
Group13[12]=22;

Not likely

grp1[] = {0,1,2};
grp2[] = {7,8,9,10};

The first line declares and array of 3 elements.
The second line declares and array of four elements.

To make like the image i poste first, i have to have this?

grp1[] = {0};
grp2[] = {1};
grp3[] = {2};
grp4[] = {3};
grp5[] = {4};
grp6[] = {5};
grp7[] = {6};
grp8[] = {7};
grp9[] = {8};
grp10[] = {9};
grp11[] = {10};
grp12[] = {11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21};
grp13[] = {22};
(...)

To make the first 10 pixeis alone, and then 11 grouped, yes?

And then, how to rainbown this?

void rainbow() 
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, NUM_LEDS, gHue, 5);
}

void rainbowWithGlitter() 
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(100);
}

void addGlitter( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

Any idea? :frowning:

Not sure if fastled can do a rainbow with groups. You may need to do rainbow over a CRGB array with the same number of elements as you have groups, then copy the colors over to you strip.

You have an arrangement of LEDs that is 25 columns wide (not counting empty columns). If you create an array that maps each individual LED to its corresponding column position, then you can have FastLED generate a 25-pixel wide rainbow pattern, to get the colors for each of the columns in your display, then set the color of each of your LEDs to the color for the column in which it resides. Here is an example, might be easier to understand than my trying to describe what it is doing:

#include <FastLED.h>

#define NUM_LEDS 53
#define DATA_PIN 12
#define DISPLAY_COLUMNS 25 //display is 25 columns wide
CRGB leds[NUM_LEDS];

byte gHue;

//map each pixel to its column position in the display
byte ledmap[NUM_LEDS] = {
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10,
  10, 10, 10, 10, 10, 11, 12, 12, 13, 13, 14, 15, 16, 17, 18, 18,
  18, 19, 19, 20, 21, 22, 23, 23, 24, 24, 24, 24, 24, 24, 24, 23,
  22, 21, 21, 20, 19
};

void setup() {
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
  FastLED.setBrightness(32);
  FastLED.clear();
  FastLED.show();
}

void loop() {
  gHue = random(255);
  rainbow();
  FastLED.show();
  delay(10000);
  rainbowWithGlitter();
  FastLED.show();
  delay(10000);
}

void rainbow()
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, DISPLAY_COLUMNS, gHue, 5);
  map_leds();
}

void rainbowWithGlitter()
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(100);
}

void addGlitter( fract8 chanceOfGlitter)
{
  if ( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

void map_leds()
{
  for (int8_t i = NUM_LEDS - 1; i >= 0; i--) {
    leds[i] = leds[ledmap[i]];
  }
}

Note that I've had FastLED generate the rainbow pattern using the leds[] array, then done the copying from the end of the strip towards the beginning, with your arrangement of LEDs that works without overwriting the rainbow pattern, if the LEDs had been arranged differently it might have been necessary to store the rainbow pattern outside the leds[] array to prevent altering it in the process.