"Paul B. Webster VK2BZC" wrote: > Four switches eh? OK, match them with four bits in a register which > we call "previous", and a 4-bit variable called "count". It should be > fairly obvious that one byte can be used for both. > > Depending on how you wish your timing loop to perform, you may at this > point proceed to your "other" task for a further 2 ms, or loop back and > find any other switch that does not match "previous". In either case, > if there was only one switch changed (and most of the time, there will > only be one), the next iteration finds the switches match "previous", > and "count" is reset to $F. > > Is this clear enough? Very. A nice variation would be to sample slightly slower, to check the counter before you reset it to $F, and also check if "new" is the default state. Now you can react differently to "long" keypresses than "short" ones. -- Friendly Regards /"\ \ / Tjaart van der Walt X ASCII RIBBON CAMPAIGN mailto:tjaart@wasp.co.za / \ AGAINST HTML MAIL |--------------------------------------------------| | WASP International | |R&D Engineer : GSM peripheral services development| |--------------------------------------------------| | Mobile : tjaart@sms.wasp.co.za (160 text chars) | | http://www.wasp.co.za/~tjaart/index.html | |Voice: +27-(0)11-622-8686 Fax: +27-(0)11-622-8973| | WGS-84 : 26¡10.52'S 28¡06.19'E | |--------------------------------------------------|