I am wondering how to use PWM to adjust colours for an RGB LED if the LED is already set as a GPIO_Output? (so I cannot also set them as a timer(s)).
- 9 replies
- 4858 views
Hi all, I am currently writing a program that uses the STM32L432KC board (nucleol432kc) and a thermistor to obtain a temperature and then display that temperature on an LCD, a terminal screen, as well as turn an RGB LED on with different temperature ranges corresponding to different colours (ex. temp lower than 20 degrees C, blue led on...etc) Each component is currently working perfectly, the only extra thing I cannot figure out is how I can use PWM (and how to set up the configuration for it) to change the colours to different mixes of RGB. I have each leg of the RGB LED set as GPIO_Outputs, but I do not know what pin I should be setting as a timer if I want to use the PWM. I am using STM32CubeIde.
I have attached the current configuration for my board, which does work perfectly fine (so ideally I wouldn't want to make any huge changes, mostly because whenever I do it gets rid of all of my code and even when I copy and paste it back there's usually some errors). All I want to be able to do is adjust the colour mixing of the RGB LED in a way that looks like (255, 0, 0) for red, (0, 255, 0) for green... etc.
Note* the only configuration requirements are:
PA8 is red
PA9 is green
PA10 is blue
PA1 is for ADC of thermistor voltage
