0

I'm having trouble in the fill_solid function with arrays. can you help give color to row3.

int row3[]={1,2,3};
uint8_t sizerow3 = sizeof(row3)/sizeof(row3[0]);

void solid(){
  fill_solid(leds[row3[3]], sizerow3, CRGB :: Red);
  LEDS. show();
}

This is my complete program.

Thank you

2
  • 1
    What is the problem with your code? Please add a detailed problem description
    – chrisl
    Commented Mar 21, 2022 at 9:34
  • i need help how to turn on the leds from row1[] to row5[] in sequence. (per row not per pixel)
    – Ecvary
    Commented Mar 21, 2022 at 9:54

1 Answer 1

1

leds[row3[3]] is not what you think it is. That is selecting one single LED depending on what is in element 4 (index 3) of the 3-element array row3. Since there is no index 3 in a 3 element array (only indexes 0, 1 and 2) the value it returns to use as an index to the leds[] array is unknown.

fill_solid is designed to fill a single uninterrupted string of LEDs starting at LED n and progressing for a number of LEDs after that. To set random LEDs all to the same colour you should simply loop through your list of target LEDs and set the colours individually. Something like:

for (int i = 0; i < sizerow3; i++) {
    leds[row3[i]] = CRGB::Red;
}
LEDS.show();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.