It must be somewhere in the docs i'm sure, but i cannot find it...

(Remco Koffijberg) #1

It must be somewhere in the docs i’m sure, but i cannot find it… I would like to have a rainbow (or any other) effect on a subset of leds in a led strip. How to define this subset?

(Andrew Tuline) #2

For fill_rainbow, it’s normally:

fill_rainbow(leds, NUM_LEDS, thishue, deltahue);


fill_rainbow(leds+6, 3, thishue, deltahue);

(Marc Miller) #3

This would fill the whole strip with a complete rainbow (starting with hue 77).
fill_rainbow( leds, NUM_LEDS, 77, 255/NUM_LEDS);

And this would fill part of the strip with a complete rainbow (starting with hue 77). The rainbow would start on pixel number 5, and would end 5 pixels from the end.
fill_rainbow( &(leds[4]), NUM_LEDS-8, 77, 255/(NUM_LEDS-10) );

(Ken White) #4

@Remco_Koffijberg - Use CRGBSet to fill a section of a strip with a rainbow or other effects. See:

Also, see my comments in:

(Marc Miller) #5

Note Be careful that the number of pixels you’re filling does Not go past the number of leds you’ve defined for NUM_LEDS. That will cause memory issues and could lockup your program/MCU.

“Writing data to pixels that don’t exist causes bad things to happen.” (TM Daniel Garcia).

(Remco Koffijberg) #6

@Ken_White tx!!

(Remco Koffijberg) #7

@marmil Garcia, a wise man

(Remco Koffijberg) #8

In my project only some leds of the strip are visible. Is there a way to add individual leds to the CRGB set? (like only led number 5,11,14, 21 etc).

(Marc Miller) #9

No, CRGBSet needs a consecutive range of pixels.

(Remco Koffijberg) #10

@marmil Ok thanks. That saves me a lot of time! (-;

(Marc Miller) #11

@Remco_Koffijberg I forgot to come back to this post and share this… To make a specific group of pixels into a pixel set, or custom CRGB set you can do something like this:

uint8_t LED_lookupTable_length = 5; //number of pixels in set
uint8_t LED_lookupTable[] = { 1, 4, 5, 7, 9}; //specific pixels

Then to run through it, use a for loop and use the values in the table to target the corresponding LEDs:
for( uint8_t LED = 0; LED < LED_lookupTable_length; LED++) {
uint8_t pos = LED_lookupTable[LED];
leds[pos] = CRGB(255, 0, 0); //assign some color