Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

STK button detection

STK button detection

2004-01-12 by Steven Chang-Lin Yu

I am currently study someone’s code for detecting the pressing of the button of the STK board!!!

if ( keys & 1 )

led = 1;

else if ( keys & 2 ) // priority encoder: if multiple switches are pressed,

led = 2; // only the lowest switch is recognized

else if ( keys & 4 )

led = 4;

else if ( keys & 8 )

led = 8;

else if ( keys & 0x10 )

led = 0x10;

else if ( keys & 0x20 )

led = 0x20;

else if ( keys & 0x40 )

led = 0x40;

else if ( keys & 0x80 )

led = 0x80;

Can someone explain to me why the keys is compared by using 2, 4, 8, 0x10, 0x20, 0x40, 0x80!!! And is there other way of detecting it?

Thanks

Steven

__________________________________________________________________
Steven Chang-Lin Yu
ICQ#:
66369374

Current ICQ status:

( Home Tel#: 0401043641
( Work Tel#: 0401043641
+ More ways to contact me


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 8/01/2004

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.