Koen van Leeuwen email (remove spam text)
On Friday 18 June 2004 19:59, Bob Axtell wrote:
> While it would seem that testing that a key is pressed would seem
> simple, it actually isn't because most applications need to know
> when it was RELEASED as well. In fact, for me, a keypress occurs when it
> is PRESSED THEN RELEASED.
> About 10 years ago I began using a bulletproof way to process keys:
> 1. I read the keys- all of them- every 10ms or so. I can either read 'em
> all at one tome, or rotate so that I read each one on a rotating basis.
> Doesn't matter how its done, it works perfectly regardless.
> 2. Every 10ms I read the key and shift its value into a register
> decicated just for that application.
> 3. If the key is ZERO when it is pressed, I look for the pattern
> b'11110000' on that key's register. When that is seen, that key was
> PRESSED AND RELEASED, so set a flag. To prevent more action, jam the
> key's register with '11111111' so it can't be used again.
What happens with key bounce? Isn't it possible that bouncing during release
of the key would produce the pattern b'11101000'?
> This works great. If anyone is interested, I'll publish some code.
I'm interested :o)
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
In reply to: <40D32D70.email@example.com>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the