Hey guys! I’ve posted on this forum before like a year ago, got help, was content with my setup, but now want to do more. I have 2 questions, an arduino/c++ based question and a questing regarding FastLED functions. I’ll explain my project so it makes more sense.
I have 450 WS2812B lights around the perimeter of my room. Right now I have an audio jack connected into 2 MSGEQ7 IC’s to read in the audio data. The data consists of 7 frequencies from the left channel and 7 from the right. I have successfully made an audio spectrum analyzer, but am running into issues when I increase the size of the frequency “blocks”. I currently have a 1x14 setup, with each led corresponding to a frequency value…but I have 450 leds available. I decided to expand to a section 42 leds long, to test my code as well as the power draw.
-
I have defined my leds in an array, such that
CRGB leds[num_leds];
I have defined the led numbers I want for each block in arrays as well
int left_63[] = {1,2,3};
int left_160[] = {4,5,6};
int left_400[] = {7,8,9};
and so on. I run into an issue when I try to change the elements of the array all at once; I want led #'s 4, 5, and 6 to all change at once without the use of a for loop. I do this by declaring
leds[left_63] = CHSV(192,255,spectrum_left[0]);
leds[left_160] = CHSV(180,255,spectrum_left[1]);
leds[left_400] = CHSV(128,255,spectrum_left[2]));
and so on. This presents an error stating
“invalid types ‘int[int]’ for array subscript”
How do I fix this? I know what I want to do, I am unsure how to get c++ to perform this operation and I am unsure what to google as I am still a novice with c++. -
To negate the issue from problem 1, I decided to do something different in the main loop. I decided the best method was to use a for loop to re-write each array one at a time
for (int i =1; i <= 3; i++){
leds[i] = CHSV(192,255,spectrum_left[0]);
leds[i+3] = CHSV(180,255,spectrum_left[1]);
leds[i+6] = CHSV(128,255,spectrum_left[2]));
}
and so on. I start running into issues when I increase the size of the “blocks”. So if I make i <= 32, the clock on the arduino cannot keep up with the huge computational requirement, meaning my lights lag behind and each “block” slowly updates (like an old CRTV). I decided to use one of the builtin FastLED functions to fix this
fill_solid(leds,42,CHSV(192,255,spectrum_left[0]));
fill_solid(leds,39,CHSV(180,255,spectrum_left[1]));
fill_solid(leds,36,CHSV(128,255,spectrum_left[2]));
and so on. My question with this: Is there a function in the FastLED library where I can fill a certain section of lights at once instead of everyone up to the specified number? Something like
fill_solid(leds,39 through 42,CHSV…);
fill_solid(leds,36 through 39, CHSV…);
I hope I outlined my questions/problems in an easy to understand manner, and hopefully there’s an easy fix! Thanks again!
Griff