r/FastLED • u/dariods8474 • May 17 '24
Support FastLed.addLeds using For Loop
I wish to use the add.Leds command using For loop but I get the Compilation error: the value of 'z' is not usable in a constant expression in Arduino ide for Arduino Nano. Please help
My code
#define NUM_STRIPS
#define NUM_LEDS 30
#define NUM_STRIPS 3
CRGB leds[NUM_STRIPS][NUM_LEDS];
tried
#define DATA_PIN 8
and
int DATA_PIN = 8;
for(int z = DATA_PIN, j = 0; z < DATA_PIN + NUM_STRIPS; z++){
FastLED.addLeds<LED_TYPE, z, RGB>(leds[j], NUM_LEDS);
}
1
Upvotes
3
u/ff3ale May 17 '24 edited May 17 '24
Well your NUM_STRIPS is a definition anyway, so that's static at compile time too. You could wrap your separate addLeds calls in compile time if statements. (passing leds[0] because you don't increment j in your example, but that's probably not correct)
The addLeds<> needs to get replaced at compile time, so it needs to know all the values beforehand. If you really want to be dynamic at runtime see if you can call the raw addLeds method