Often I see articles in which debouncing of switches is not taken into account. This is a nice resource that shows how to debounce in HW and SW http://www.labbookpages.co.uk/electronics/debounce.html
Tech reviews and tutorials
Often I see articles in which debouncing of switches is not taken into account. This is a nice resource that shows how to debounce in HW and SW http://www.labbookpages.co.uk/electronics/debounce.html
Hello Francesco,
Cool blog!
I often use a variation of the Approach 1:
1 Setup a counter variable, initialise to zero.
2 Setup a regular sampling event, perhaps using a timer. Use a period of about 1ms.
3 On a sample event:
4 if switch signal is low then
5 Reset the counter varaible to zero
6 Set internal switch state to pressed
7 else
8 Increment the counter variable to a maximum of 10
9 end if
10 if counter=10 then
11 Set internal switch state to released
12 end if
In this case when you press the button, the “pressed” value is instantly obtained, then filter the “high state/release” bounces.
Pro: get “pressed” state sooner.
Cons: maybe little more computation time. Works well only with clean digital signals, not with noisy-analog sourced triggered signals.