Hi, I need a bit of advice.

Hi, I need a bit of advice. I am a newbie to FastLED and Arduino. I need to blink specific leds on my strip with specific frequency at the same time. E.g. while the first led is blinking 1/s, the second led 2/s. Is there any function in FastLed dealing with this? I did some research, but without any success. Thanks a lot.

FastLed 3.1.3, Arduino UNO, Win 10, leds: WS2812B

Welcome! Try out beatsin8(beatsPerMinute, minimumValue, maximumValue):

led[0] = CHSV(hue, saturation, beatsin8(60, 0, 255));
led[1] = CHSV(hue, saturation, beatsin8(120, 0, 255));

More info:

Many thanks, this is suitable for examples I have provided, however I also need to blink a led for 1s (let’s say) every 5 minutes.
Therefore the code similar to:
leds[0] = CRGB::White; FastLED.show(); delay(1000);
leds[0] = CRGB::Black; FastLED.show(); delay(300000);

but indeed it doesn’t work for many more leds to be switched on at the same time, as there is delay. Ideally, I need something like:

leds[0] = some_function_that_switches_on_and_off_led(color, miliseconds, color,miliseconds);
leds[1] = some_function_that_switches_on_and_off_led(color, miliseconds, color,miliseconds);

i.e. leds[0] will blink every second for one second …and leds[90] will blink every 5 minutes for one second.

Any suggestion appreciated.
Thank you

Try the EVERY_N macros:

EVERY_N_MILLIS(30) { leds[0] = CRGB::White; }
EVERY_N_SECONDS(2) { leds[0] = CRGB::White; }
EVERY_N_MINUTES(5) { leds[0] = CRGB::White; }
EVERY_N_HOURS(1) { leds[0] = CRGB::White; }


Jason’s got it right, and please don’t use delay statements or they will wreck your timing and render any inputs (buttons, etc) useless.

Thank you guys.

I think I’m on the right way. I have tried:
EVERY_N_SECONDS(1000) { leds[0] = CRGB::White; };
but led keeps switched on and not blinking, so I changed the code to:
leds[0] = CRGB::Black;
EVERY_N_SECONDS(1) { leds[0] = CRGB::White; }

it works pretty well, but I cannot control time of led, when is switched on. It flashes every second for cca 1ms (?).
I have an idea to test millis timing using a bit dirty way:
if (millis()%1000==0){
leds[0] = CRGB::White;
if (millis()%3010==0) {
leds[0] = CRGB::Black;

it works very well. Hope this “dirty” way is OK and the code will fit to memory. I’m using 96 leds and to address each individually will consume much of memory. I have to test it.

Anyway thank you for your suggestions.

Nothing at all wrong with that way, good work!