- 12
- 0
- 约2.63千字
- 约 10页
- 2023-09-21 发布于湖北
- 举报
!-
按下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)
{
您可能关注的文档
最近下载
- BS EN 14644-13-2017 Cleanroom 国外国际标准规范.pdf VIP
- 前后蛇行轮滑教案.docx VIP
- 07消防水停运处置预案.docx VIP
- 2025年广东省高职院校五年一贯制转段考试文化课测试(英语).docx VIP
- GB50346-2011 生物安全实验室建筑技术规范.docx VIP
- 叉车理论考试参考题库及答案3套全.docx VIP
- 2026年安全培训《易制毒、易制爆化学品管理及应急预案》考试及答案.docx VIP
- GB50010-2010 混凝土结构设计规范(2015年版).pdf VIP
- 水工监测工(技师)试卷及答案.docx VIP
- SY 4201.2-2016 石油天然气建设工程施工质量验收规范 设备安装工程 第2部分:塔类.docx VIP
原创力文档

文档评论(0)