>It sound very noisy button. I have not seen 30 ms bouncing signal >coming from a button. I assume you did not see it under a >osciloscope. My avagare bouncing lasts for less than one ms. I use >three successive stable readings to validate a keystroke within 12ms >periodic polling to read matrix key strokes and it works just fine. I've got a truckload of those buttons :( I shouldn't really complain because it has allowed me to come up with some pretty efficient routines for debouncing. If you're polling the button (no interrupts) the algorithm is: DebounceLoop: ; Come Back Here to Wait for the keypress if Button_Up goto DebounceLoop Counter = 20 msec delay ; Wait a solid 20 msec to assume good down DebounceWaitLoop: ; Button in this loop Counter = Counter - 1 if Counter == 0 goto DebounceEnd if Button_Up goto DebounceLoop ; If Button goes up, start over goto DebounceWaitLoop DebounceEnd: ; Button is down and Debounced Note that I continuously poll the button and if it ever goes back up I restart the process. Note that the same thing should be done for the button release. If you want to do this concurrently with something else, TMR0 and the INT0 Pin (or Interrupt on State Change Pins) can be used as part of an interrupt handler. If you have a noisy switch, just polling it every 10 msec or so will not give you a reliable keypress. For a good quality switch, it should be fine (read the specs and get one that "clicks" down and up - this will minimize the problems). Good luck, myke >Aydin > >> I am planning to debounce a simple pushbutton connected to a PIC input with >> weak pullups enabled. My strategy is to read the button every 10ms, and >> when 4 successive reads are the same, consider the level valid. This will >> of course mean that the button level must be the same for at least 30ms to >> be considered valid. The algorithm I am using will easily allow checking >> for up to 8 matching reads, any more than that and I'll have to change the >> method. >> >> Any comments on this? Is 10ms about right? How about using 4 successive >> reads, is this enough, too many, etc.? >> >> >> TIA - Martin R. Green >> elimar@bigfoot.com >> > > "If at first you don't succeed, then maybe sky diving isn't the sport for you" - Steve Smith