Herbert Graf wrote: > Stave wrote: > > Ah ! One of my pet peeves. > > If you didn't do it backwards, there wouldn't be a delay. Why are you > > waiting for the switch to finish bouncing ? Start acting as soon as you > > detect the first closure and then ignore any activity for the worst case > > bounce time. > > This has been taught wrong since Adam was a boy and nobody has > > thought about it since. > > It hasn't been taught "wrong". Power supply glitches (or any other form of > noise) can cause a button to "appear" to be pressed, your technique would > trigger on such a "button press". It's worse for a device to respond to a > false button press then to not respond at all in many cases. Guess you > didn't think about that. No, Steve has it right. Leading edge switching makes a huge difference in customer perception, even at the 50 - 100 ms level. If you have so much crap floating about in your system that a power supply transient can look like a bouncing switch, then you've got worse problems than user perception. You need to deal with that separately (e.g., filters, hysteresis, and in extreme cases, double-throw switches), and not rely on the switch debounce function to hide it. -- Dave Tweed -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu