It is currently Sun May 26, 2013 11:09 am

All times are UTC + 10 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: The secret life of switches
PostPosted: Sat Apr 23, 2011 7:33 am 
Offline
I practically live here!
I practically live here!

Joined: Sun Mar 28, 2010 1:36 pm
Posts: 688
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.


Top
 Profile  
 
 Post subject: Re: The secret life of switches
PostPosted: Sat Apr 23, 2011 6:42 pm 
Offline
Moderator
Moderator
User avatar

Joined: Sun Mar 28, 2010 9:03 pm
Posts: 699
Location: United Kingdom
Thats very true, thats why when programming a microchip after a switch being pressed we had some code a bit like this:
Code:
if button = pressed then
    // put your code here
    delayms(20)     //==== debounce delay for button
endif


Has you can see the delayms is the switch debounce delay.


Top
 Profile  
 
 Post subject: Re: The secret life of switches
PostPosted: Sat Apr 23, 2011 9:22 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Fri Mar 26, 2010 10:30 pm
Posts: 1865
Or how about this one :D

Code:
Sub CheckButton()
     If ButtonDebounce <> 0 then
          dec(ButtonDebounce)
     Else
          If ButtonPressed = true then
               ButtonDebounce = 10
               do this code here...
          Endif
     Endif
End Sub


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme made by Keenen Wheeler