Adding Colors to Led Using Fastled

I am trying to add colors that I set to an led using FastLED library on arduino

Currently I am using fill_solid like so,

leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)).fill_solid(CRGB(255,0 ,0));
FastLED.show();

However, I am not able to add colors to it after this has been set. Ideally I would like something like so,

leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)).fill_solid(CRGB(255,0 ,0));
FastLED.show();
leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)).fill_solid(CRGB(0,255 ,0));
FastLED.show();

And the led would glow with RGB = (255, 255, 0)

Is there any way to achieve this without keeping state information and just add to the existing color using FastLED?

2 Answers

leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)) += CRGB(0,255,0); should do what you want (I’m pretty sure I checked that support in for the pixelviews)

3

leds is just an array of RGB values so you can just iterate through it with a for loop and modify the values. In this case += will work.

For example:

for (int i=0; i<NUM_LEDS; i++) leds[i] += CRGB(0,255,0);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest