按下16个矩阵键盘依次在数码管上显示16的平方.docVIP

  • 12
  • 0
  • 约2.63千字
  • 约 10页
  • 2023-09-21 发布于湖北
  • 举报

按下16个矩阵键盘依次在数码管上显示16的平方.doc

!- 按下16个矩阵键盘依次在数码管上显示1-16的平方 Proteus 仿真原理图: 程序: /*3,按下16个矩阵键盘依次在数码管上显示1-16的平方。如按下第一个显示1,第二个显示4... */ #includereg52.h #define uchar unsigned char #define uint unsigned int uchar code table1[]={ 0xfc,0x60,0xda,0xf2,0x66, 0xb6,0xbe,0xe0,0xfe,0xf6}; uchar code table2[]={0x1f,0x2f,0x37}; void delay(uint); void keyscan(); void display(uint); void main() { while(1) { keyscan(); // display(16); } } void delay(uint z) { uint x,y; for(x=z;x0;x--) for(y=110;y0;y--); } void keyscan() { uchar temp,key; P3=0xfe; temp=P3; temp=temp0xf0; if(temp!=0xf0) { delay(10); temp=P3; temp=temp0xf0; if(temp!=0xf0) { temp=P3; switch(temp) { case 0xee: key=1; break; case 0xde: key=2; break; case 0xbe: key=3; break; case 0x7e: key=4; break; } while(temp!=0xf0) { temp=P3; temp=temp0xf0; } } } P3=0xfd; temp=P3; temp=temp0xf0; if(temp!=0xf0) { delay(10); temp=P3; temp=temp0xf0; if(temp!=0xf0) { temp=P3; switch(temp) { case 0xed: key=5; break; case 0xdd: key=6; break; case 0xbd: key=7; break; case 0x7d: key=8; break; } while(temp!=0xf0) { temp=P3; temp=temp0xf0; } } } P3=0xfb; temp=P3; temp=temp0xf0; if(temp!=0xf0) { delay(10); temp=P3; temp=temp0xf0; if(temp!=0xf0) { temp=P3; switch(temp) { case 0xeb: key=9; break; case 0xdb: key=10; break; case 0xbb: key=11; break; case 0x7b: key=12; break; } while(temp!=0xf0) { temp=P3; temp=temp0xf0; } } } P3=0xf7; temp=P3; temp=temp0xf0; if(temp!=0xf0) { delay(10); temp=P3; temp=temp0xf0; if(temp!=0xf0) {

文档评论(0)

1亿VIP精品文档

相关文档