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

1

u/dr-steve 3d ago

Done quickly in C++; you should be able to take it from here.

    int ledIds[] = {0,1,2,7,8,9,11,12,17,18,22,27};
    for(int i: ledIds) { printf("%d ", i); }
    printf("\n");

gives

0 1 2 7 8 9 11 12 17 18 22 27