What is the Fastled command to control the whole strip of light at once?

What is the Fastled command to control the whole strip of light at once?
And how do I control a portion of a strip (say, pixel 24-38) simultaniously?

Can I use:
leds[24-38].setRGB( 255, 68, 221); ???

Thank you for your help!

Try something like…

fill_solid( leds, NUM_LEDS, CRGB::Red);

for your whole strip.

Thank you.
But can I control the amount of RGB-colours with fill_solid?

yes of course you can say…

fill_solid( leds, NUM_LEDS, CRGB(50,75,100));

Ah! Perfect. Thank you very much!
How about the range of pixels? Anyone have an idea there?

Note there are other similar functions like…

fill_rainbow

and…

fill_gradient

for more info on these you will probably have to dive into the library code itself.

@John_Inge_Ellingsaet

If you look into the command…

fill_solid( leds, NUM_LEDS, CRGB::Red);

leds, is actually pointing to the beginning of the leds array.

NUM_LEDS is the whole size of your array.

Just give the function another valid pointer within your strip and some valid LENGTH as you want !

For example…

fill_solid(leds+5, 10, CRGB::Blue);

will fill the 10 LEDs starting at leds[5] with the color blue.

Big thanks Roy!
Will help loads!

John

@John_Inge_Ellingsaet

I think, but not 100% sure, that the fill_solid function is not more efficient than let’s say a simple for loop as the compiler will probably produce the same thing at the end!

It does however makes your code look a little bit tidier!

Can I use a potmeter and

FastLED.setBrightness(potValue);

in my loop to control the overall brightness of my pixels?

Yes, just make sure your pot values are in the range 0-255.

You will need to map the value received from the analog read that is 0-1023 like this…

val_0 = analogRead(0);
brightness = map(val_0, 0, 1023, 0, 255);
FastLED.setBrightness(brightness);

It’s a little more complex than that - your actual range out of the pot may not fill the entire 0-1023 range which may mean you never hit full brightness. So you’ll want to do some testing to check on the range you are getting.

Awesome.
Sorry for just asking instead of trying by the way. Just a little pressed on time, so asking rather than experimenting.

Making some DMX-controlled RGB-letters for a school stage performance… that starts on wedensday… :slight_smile:

@Daniel_Garcia I have not noticed this on any setup with potentiometers hooked up to 5V.

What would cause this reduced range ?

Just noticed on Arduino site that the Due and the new Zero have 12 bits resolutions so 0-4096 ranges.

It’s been a couple of years since I used hardware controls for much (bluetooth/wireless/serial control all the way :). However, I remember dumping out values from analogRead and having them rarely go up above 750-800 with the hardware that I was using. Got me in the habit of having calibration code that would basically map the highest/lowest values ever seen off of that pin and use that for the range to work with.

I found if I connected the outside pins of the pot to AGND and 3.3V on my Teensy, with the pot’s middle pin on one of the Teensy’s analogue pins, I got values over the whole 0-1023 range.