請(qǐng)求51單片機(jī)c語(yǔ)言關(guān)于矩陣鍵盤(pán)掃描程序的詳解 謝謝了 部分程序如下
void keyscan(void) { char col,row; char scanline=0x08; int key=0; int keystatus; for(col=0;col<4;col++) { P2=~scanline; keystatus=~P2; keystatus&=0xf0; for(row=0;row<4;row++) { if(keystatus==0x80) { one=0; if(keytemp!=key) { keytemp=key; zero=1; } else { zero+=1; if(zero==5) keydata=keytemp; } } key+=1; keystatus<<=1; } } one+=1; if(one==5) { zero=0; keytemp=0xff; keydata=0xff; } }
歡迎光臨 (http://www.torrancerestoration.com/bbs/) | Powered by Discuz! X3.1 |