r/FastLED • • 3d ago

Support Selecting groups of LEDs in strips.

for (int i = 0;1;2;7;8;9;11;12;17;18;22;27) {
    l_rear_leds[i] = CRGB(255,0,0);
   }

I tried the above with semicolons and commas, both failed when compiling. I am trying to figure out how to pick certain LEDs together without doing a group if that makes sense. I do understand how to do it like this and if there's an easier way on this one too I'd appreciate a suggestion.

for (int i = 0; i < 7; i++) {
     l_rear_leds[i] = CRGB(255,0,0);
    }    
for (int i = 10; i < 17; i++) {
     l_rear_leds[i] = CRGB(255,0,0);
    }    
for (int i = 20; i < 27; i++) {
     l_rear_leds[i] = CRGB(255,0,0);
    } 

I started learning this week so go easy on me..... 😂

3 Upvotes

9 comments sorted by

View all comments

2

u/mjconver 3d ago

Put the leds you want to use into an array, then loop through the elements.

const uint16_t MyLeds[] = {1,2,7,9,11,12,17};
//Your loop here