Hello Arduino forum,
Working on programming a WS2812b LED strip.
Started with an Example in the FastLED library
and stripped it down to just go in one direction
and remove any other extraneous code. Got that
working.
Also would like to wiped the strip clear before
repeating the chase. So added to the end of the
chase code the lines that begin:
"for (int NUM_LEDS=0; NUM_LEDS<TOTAL_LEDS;"
and end with "strip.show();"
When compiled the result is:
"Compilation error: expected unqualified-id before numeric constant"
Research indicates that this error is cause by beginning a variable with a number. But the variable is "NUM_LEDS"
which is not a number.
Why is the IDE complaining about the variable?
Thanks.
Allen Pitts
/// @file Cylon.ino
/// @brief An animation that moves a single LED back and forth (Larson Scanner effect)
/// @example Cylon.ino
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 80
#define DATA_PIN 3
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
FastLED.setBrightness(84);
}
void loop() {
static uint8_t hue = 0;
//Serial.print("x");
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
delay(10);
}
for (int NUM_LEDS=0; NUM_LEDS<TOTAL_LEDS; NUM_LEDS++)
{
strip.setPixelColor(NUM_LEDS, 0,0,0);
}
strip.show();
}