Library for LED brightness and strobe/flashing control

Hi,

Is there some popular, well maintained library for controlling LED brightness (dimmer) while also optionally enabling strobe i.e. flashing effect ? Ideally, this library should be able to coexist with other functions that need to be invoked from the main loop(), that too are to be repeatedly invoked, and should not prevent usage of delay() and delayMicroseconds().

cheers,
J

Welcome to the forum

It will be the use of delay() that prevents the LED control working properly not the other way round

1 Like

@UKHeliBob thanks for the warm welcome. Could using delayMicroseconds() somehow avoid interference ?

Check out the BlinkWithoutDelay example in the IDE

delay() and delayMicroseconds() both stop the sketch from doing anything else whilst the delay is in progress, obviously one for longer than the other

Why not use millis() and/or micros() for your timing and avoid blocking the free running of your sketch ?

The definition and the usefulness of the delay() function is that it stops program execution and waits. To ask it to do something different, breaks that definition, so the code that uses it would no longer have any logical foundation. Think about it for a while.

You probably don't need a library but you MIGHT want to write a function (or two).

Dimming is built-in with analogWrite(), unless you are using addressable LEDs.

A function is similar to a subroutine in other languages (like BASIC). When you call the function the code takes a "detour" to run the code in the function and the returns where it left-off.

The examples in that link are for ANSI / ISO standard C and they will not run on the Arduino. But the structure is the same with a function prototype, a function definition, and one or more function calls.

A function can also return ONE value, or pointer to an array, etc.

The function can be conditionally called (with an if-statement and millis(), etc.)

A library usually contains multiple functions.

1 Like

That certainly helped. Thanks.

Understood. Thanks. I am relatively new to Arduino programming, though not to programming in general, so struggling with some of the concepts.

Thank you all. Managed to do the mixed brightness control (using PWM pin) and strobe-effect (flashing) using the logic found in "blink without delay". It works perfectly, and is quite simple, once understood.

1 Like

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