# LED Array question..  How do I create an array of non-sequential LEDS?

(Erin St. Blaine) #1

LED Array question…

How do I create an array of non-sequential LEDS? I have a starfish-shaped setup and I want to be able to call the outermost led on each “arm” at the same time. I can’t seem to figure this out.

So I want an array consisting of LED # 10, 20, 30, 40, 50, and 60, and another consisting of 9, 19, 29, 39, 49, and 59. What does the syntax look like? I tried:

bottomrow [10, 20, 30, 40, 50, 60]

… and that doesn’t do it, it just lights up LED 60… any hints?

(Daniel Garcia) #2

uint8_t bottomrow[NUM_ARMS] = { 10, 20, 30, 40, 50, 60 };
uint8_t nextbottomrow[NUM_ARMS] = {9,19,29,39,49,59 };

// set all the outermost leds to white, and next outermost to blue
for(int i = 0; i < NUM_ARMS; i++) {
leds[bottomrow[i]] = CRGB::White;
leds[nextbottomrow[i]] = CRGB::Blue;
}

(Daniel Garcia) #3

The reason why what you did doesn’t work is that in C - if you have two expressions separated by a comma used in a place where a single expression is expected (i.e. the index of an array) the value of that entire “expression” is the rightmost value. So, leds[5,10] = CRGB::White would just set led 10 to white.

(Erin St. Blaine) #4

ooh that did it. Thank you so much!