http://www.eetimes.com/discussion/break ... f-switches
When you open or close a switch, they sometimes touch multiple times and when you use high speed microcontrollers, sometimes you can get multiple results for the switch which could cause problems. This article gives you a little insight.
The secret life of switches
Moderators: Chuckt, Garth, bitfogav
Re: The secret life of switches
Thats very true, thats why when programming a microchip after a switch being pressed we had some code a bit like this:
Has you can see the delayms is the switch debounce delay.
Code: Select all
if button = pressed then
// put your code here
delayms(20) //==== debounce delay for button
endif
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: The secret life of switches
Or how about this one

Code: Select all
Sub CheckButton()
If ButtonDebounce <> 0 then
dec(ButtonDebounce)
Else
If ButtonPressed = true then
ButtonDebounce = 10
do this code here...
Endif
Endif
End Sub
Who is online
Users browsing this forum: No registered users and 5 guests