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

chrisl
16.6k2 gold badges18 silver badges27 bronze badges
asked Mar 21, 2022 at 8:51
2
  • 1
    What is the problem with your code? Please add a detailed problem description 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) 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();
answered Mar 21, 2022 at 10:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.