Leds[i] = CRGB ( r,g,b)

Hi All,

I am new to Arduino FASTLed and want to know what does the below syntax mean?
leds[i] = CRGB ( r,g,b)

Thank you,
Amy

It looks like you're using FastLED. FastLED sketches conventionally use an array called leds to hold the colour information for the LEDs.

That specific line sets the colour of LED number i to have the RGB values r, g and b. So leds[0] = CRGB(255, 255, 255); would set the 0th LED to white.

1 Like

Thank you for such a quick reply.

for (int i = NUM_LEDS/2; i >= 0; i--)
{
leds[i] = CRGB ( r,g,b);
leds[NUM_LEDS-i] = CRGB (r,g,b );
delay(40);
FastLED.show();
}

This is the whole code. Please help me understand what exactly it does.

Thanks again!

In plain English, that will slowly change all LEDs on a strip to a new colour, starting from the edges and meeting in the middle.

1 Like

you don't seem to be changing the value of r,g,b here. try CRGB ( i,i,i);

1 Like

Sure, I will try that out

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.