Using int to define array size error with FastLED.

I am trying to get my little LED strip to work. With the code below - it works. But, I have magic numbers. So, I created two int variables...

My code below works, but I am NOT using the variables, as you can see:

#include "FastLED.h"

int NUM_LEDS = 10;
int STRIP_PIN = 7;

CRGB leds[ 10 ];

void setup() {
FastLED.addLeds<NEOPIXEL, 7>(leds, 10);
}

void loop() {
for(int i = 0; i < 10; i++) {
leds = CRGB::Green;

  • FastLED.show();*
  • delay(10);*
    _ leds = CRGB::Black;_
    * FastLED.show();*
    * delay(10);*
    * }*
    }
    As soon as I set the line "CRGB leds[ 10 ];"
    to
    CRGB leds[ NUM_LEDS ];
    I get a compiler error:
    sketch_may19a:6:21: error: array bound is not an integer constant before ']' token
    CRGB leds[ NUM_LEDS ];
    I'm unsure why I am getting this and how I should be doing it.
    My board is a Arduino Nano (Old Bootloader)

Change

int NUM_LEDS = 10;

to

const int NUM_LEDS = 10;

You are defining an array of type CRGB, and the compiler wants a specific number of elements for the definition. Since NUM_LEDS is not defined as a constant, even though you gave it an initial value, the compiler isn't going to assume that it will always have that value.

Thanks so much. Fixed it and working. Thanks!