I’m having a problem using setting colors when using CRGB set with Arduino here’s my code:
#define NUM_LEDS 36 // sets the number of LEDS
#define DATA_PIN 3 // defines the data pin
#define BRIGHTNESS 50
int flashDelay = 400; // defines how long to wait between flashes
CRGB rawleds[NUM_LEDS];
CRGBSet leds(rawleds, NUM_LEDS);
CRGBSet leds1(leds(0,11));
CRGBSet leds2(leds(12,23));
CRGBSet leds3(leds(24,36));
struct CRGB * ledsarray[] = {leds1, leds2, leds3};
void setup() {
Serial.begin(9600);
// sets up the library for WS2812B type LEDs on DATA_PIN with Green, Red, Blue color order
// on the leds[] array containing NUM_LEDS LEDs
delay (2000); // delay for safety
LEDS.addLeds<WS2812B,DATA_PIN,GRB>(leds, NUM_LEDS);
LEDS.setBrightness(BRIGHTNESS); // sets brightness of LEDs to previously defined BRIGHTNESS
}
void loop() {
for (int x = 0; x < 3; x++)
{
ledsarray[x]=CRGB::Blue;
Serial.println(x);
FastLED.show();
delay (flashDelay);
ledsarray[x]=CRGB::Black;
FastLED.show();
delay (flashDelay);
}
/*fill_solid (ledsarray[1],11, CRGB::Red);
FastLED.show();
delay (flashDelay);
fill_solid( ledsarray[1], 11, CRGB::Black);
FastLED.show();
delay (flashDelay);
fill_solid (ledsarray[2], 11, CRGB::Purple);
FastLED.show();
delay (flashDelay);
fill_solid (ledsarray[2], 11, CHSV(0,0,0));
FastLED.show();
delay (flashDelay);
/
}
The compiler gives me a "cannot convert ‘CRGB::HTMLColorCode’ to 'CRGB’ in assignment" error. Currently, the only way I can use CRGBset is by using fill_solid() (the commented out code works fine). Assigning a color to a single LED works when using leds(x)=CRGB(255, 0,0) or CRGB::Red, it’s only when using CRGBset when it becomes a problem.
Any help?