cancel
Showing results for 
Search instead for 
Did you mean: 

hello I am developing an application that does led control with a button, I use a counter for this, but every time I hold the button, the counter increases more than 1

Yçalı.1
Associate

So even if I hold the button down, I want it to increase once.

1 REPLY 1
Peter BENSCH
ST Employee

Maybe you should debounce the button, as mechanical buttons bounce, i.e. may create more than one pulse per button press.

There are several techniques to do that, one of the easiest is to connect some small capacitor in parallel to the button, which together with the pull resistor forms some low pass filter. The time constant of that filter should be slightly lower than the period of the maximum speed to press that button (e.g. 100..200ms). You will find this solution also at the NUCLEO or DISCOVERY boards.

Good luck!

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.