r/FastLED • u/QusayAbozed • Aug 14 '23
Support LED blinking using EVERY_N_MILLISECONDS
Hello Good people i am new in FastLED and i am trying to make led blinking using EVERY_N_MILLISECONDS but i have difficulties to make it i tried to much but i didn't reach to idea i need so i will be thankful if you helped me with this i am not looking just for solution i also looking for understanding the way of EVERY_N_MILLISECONDS works thanks
i will put the code down below
uint8_t off_led = 1000;
}
void loop() {
if(s==1)
{
EVERY_N_MILLISECONDS(1000)
{
leds[0]=CRGB::CRGB::LightYellow;
s=!s;
FastLED.show();
}
}
else
{
EVERY_N_MILLISECONDS(500)
{
leds[0]=CRGB::Black;
s=!s;
FastLED.show();
}
}
}
5
u/sutaburosu [stavros] Aug 14 '23
You're asking for a light to be turned on every 1.0 seconds, and also asking for that same light to be turned off every 0.5 seconds. The light may be lit for a brief fraction of a second, but it will be almost immediately turned off by the 500ms timer.
Instead, you could think of how frequently of the light should change state, e.g. every 0.5 seconds, swap the state of the light.
4
u/Marmilicious [Marc Miller] Aug 14 '23
Yo, I heard you like to blink LEDs! ;)
https://github.com/marmilicious/FastLED_examples/blob/master/blink_variations.ino
Hopefully this example will give you some different ideas of ways to blink an LED, including using EVERY_N*.
2
u/johnny5canuck Aug 15 '23
and there's a whole lot more ways to blink an led.
Shortest I've seen is 50 characters total for the program.