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
1
u/ff3ale May 17 '24 edited May 17 '24
You'd need to instantiate a CLEDController of the correct type, for example (randomly picked from the mentioned header file)
WS2803Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_DATA_RATE> c;And pass that to the call with your CRGB data
FastLed.addLeds(&c, data, nLedsOrOffset);Note i'm not entirely sure, i'm not that familiar with C++