Skip to main content
WKhan.2
Associate III
April 30, 2021
Question

How to control the blinking rate of RGB LED?

  • April 30, 2021
  • 4 replies
  • 2007 views

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

This topic has been closed for replies.

4 replies

MM..1
Super User
April 30, 2021

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 ...

WKhan.2
WKhan.2Author
Associate III
April 30, 2021

@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
Associate
April 30, 2021

Hi @WKhan.2​ ,

Please refer to the AN2531 for more details.

Hope this helps.

Best Regards,

Ons.

WKhan.2
WKhan.2Author
Associate III
October 27, 2021

Thanks for the suggestion.