cancel
Showing results for 
Search instead for 
Did you mean: 

How to control the blinking rate of RGB LED?

WKhan.2
Associate II

Hi there!

I have been trying to interface the RGB LED with STM32L152RE. My requirement is not only to control its color but also its blinking rate. I used a timer for generating PWM signals on its three channels to control different colors of RGB LED. My question is: How should I control the blinking rate of RGB LED?

One possible solution which might be implemented is to use another timer and to generate PWM on its one of the channels. By detecting the rising and falling edge of the pulse of PWM signal I could turn on the LED at rising edge and turn off the LED at falling edge.

What do you think about this solution? Is there any other simple solution besides this?

Thanks in advance.

BR

WK

4 REPLIES 4
MM..1
Chief II

Sorry , but your question is out of normal. When you know what is PWM and howto setup timer , then you have all info.

When you plan blink concrete colour then you start and stop PWM as you describe with next timer or rtos or ...

@MM..1​  Thank you for the reply. Actually I want to implement the whole idea with only two timers. One timer which controls the color scheme of RGB LED whereas the other timer would control the rate of blink. If I may ask, is it possible to generate PWM from second timer (for controlling on and off time of LED) and also at the same time to capture the rising and falling edge of the pulse by this second timer?

Ons KOOLI
Senior III

Hi @WKhan.2​ ,

Please refer to the AN2531 for more details.

Hope this helps.

Best Regards,

Ons.

WKhan.2
Associate II

Thanks for the suggestion.