??? 10/19/06 23:21 Read: times |
#126784 - I get this one. OK Responding to: ???'s previous message |
I use software for debounce switch. Get this
//-------------------------------------------------------------------------- #include <reg51.h> #define inkey P0 #define scan P2 void init_key(void) {inkey=0xFF; /* set all row to high */} unsigned char scankey(void) /* 0-255 value available return. */ { /* Use it for index lookup table ascii char in,out,row,col,pressed; while(1) {pressed=0; /* flag for chek key has pressed */ out = 0x01; for(col=0;col<=5;col++) { scan = ~out; in = ~inkey; if(in!=0) /* key pressed */ { pressed = 1; /*set flag for find key that prssed*/ break; } out<<=1; /* shift bit for scan next column */ } if(pressed) /* find what key has pressed */ { row=0; while(in>>(row+1)!=0){row++;} return ((row*6)+col); } } } //--------------------------------------------------------------------------- void main(void) { unsigned char ch; init_key(); char co_key[]={ '0','1','2','3','4','5','6','7', '8','9','a','b','c','d','e','f', 'g','h','i','j','k','l','m','n', 'o','p','q','r','s','t','u','v', 'w','x','y',0x21,0x22,0x23,0x24,0x25, 0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D }; ch = co_key(scankey()); // get character on variable 'ch' .... .... .... } /* CE KMITL 2006 ake*/ |
Topic | Author | Date |
About key 8x6 with 805, how i scan for get it key. | 01/01/70 00:00 | |
Check voltage levels at port 0 | 01/01/70 00:00 | |
Scope | 01/01/70 00:00 | |
I get this one. OK | 01/01/70 00:00 | |
How to post code![]() | 01/01/70 00:00 |