cancel
Showing results for 
Search instead for 
Did you mean: 

LED Brightnes STM32F3

Mitja Celec
Associate
Posted on October 27, 2017 at 19:10

So I have an assigment where I need to do the following:

- 10stages of brightnes (from lowest to highest)

- at each button press we change stage for 1

- first brightnes is going up, when reaches maximum is going down (does not jump to 0)

- button needs to be linked to timer, so timer does the counting and not the program

I'm totally new in electronics and in programming ARM. I know how to check for button press,how to toggle LED and where to set up PWM.

I know that LED brightnes needs to be controlled by PWM. What I don't know is how to corectly set up pulse,period of PWM and all that stuff about button click.

I would appricate any help.

#pwm #led
2 REPLIES 2
Posted on October 28, 2017 at 16:50

Show the code framework you have already built, and we'll discuss it in that context, I'm not looking to carry you.

Discuss with the person setting the assignment, and review course notes related to the task, if it still doesn't make sense talk with your teacher and classmates.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Posted on October 28, 2017 at 16:53

Find an STM32Cube example (from a nucleo or discovery board using the same STM32 as you need) with Timer PWM output. Connect the PWM output to your LED.

Button management will simply require in the main() to have a GPIO input pin with pull-up resistor (the button press shorts to ground), and poll this button every 10 msec. If the buttons goes low 3 times in a row (glitch and debounce filter), you can change the PWM value (the relation between PWM duty cycle and brightness is non linear, it increase fast at low duty, then slows: Use a 10 entry duty array lookup table.

There should be plenty of examples around.