我初學,,寫了一個單片機矩陣鍵盤的程序 有幾個問題: 1:數碼管會顯示0;我程序開始的時候讓P1=0x00; 2:只有3,7,b,f按鍵有用 希望高手幫我解決 圖,Proteus 電路圖在附件里面 下面是我程序: char b[]={0xfe,0xfd,0xfb,0xf7}; char c[]={0xee,0xde,0xbe,0x7e,0xed,0xdd,0xbd,0x7d,0xeb,0xdb,0x7bb,0x7b,0xe7,0xd7,0xb7,0x77}; int temp,num=0; void key(char); void main() { P2=0x00; P1=0xff; while(1) { key(0); key(1); key(2); key(3); } } void key(char x) {P1=b[x]; temp=P1; if(temp!=b[x]) {temp=P1; if(temp==c[0+4*x]) num=0+4*x; if(temp==c[1+4*x]) num=1+4*x; if(temp==c[2+4*x]) num=2+4*x; if(temp==c[3+4*x]) num=3+4*x; P2=a[num]; }else ; } |