吃土少年Hollar
4*4矩阵键盘扫描程序如下:uchar kbscan(void){ unsigned char sccode,recode; P1=0x0f; //发0扫描,列线输入 if ((P2 & 0x0f) != 0x0f) //有键按下 { delay(20); //延时去抖动 if ((P1&0x0f)!= 0x0f) { sccode = 0xef; //逐行扫描初值 while((sccode&0x01)!=0) { P1=sccode; if((P1&0x0f)!=0x0f) { recode=(P1&0x0f)|0xf0; while((P1&0x0f)!=0x0f);//等待键抬起 return((~sccode)+(~recode)); } else sccode=(sccode<<1)|0x01; } } } return 0; //无键按下,返回0}
优质会计资格证问答知识库