您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 电子设计/PCB > 基于单片机4X4矩阵键盘控制数码管显示的Proteus仿真
Proteus班级:电信13-2姓名:段学亮邓成智崔俊杰邓石磊陈亮高金玉成绩:4x4矩阵键盘控制数码管显示电子与信息工程学院信息与通信工程系11.设计要求单片机的P3口的P3.0~P3.7连接4×4矩阵键盘,P0口控制一只数码管,当4×4矩阵键盘中的某一按键按下时,数码管上显示对应的键号。例如,1号键按下时,数码管显示“1”,14号键按下时,数码管显示“E”等等.2.仿真电路图仿真电路图,如图一图1:4*4键盘控制数码管显示3.仿真C51程序#includereg52.h#defineucharunsignedchar#defineuintunsignedintsbitdula=P2^6;sbitwela=P2^7;uchardisnum,temp,key;voiddelay(uchari)P2.6P2.7XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435P0.5/AD534P0.6/AD633P0.7/AD732P1.0/T21P1.1/T2EX2P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C52K0K1K2K3K4K5K6K7K8K9KAKBKCKDKEKFX1C122PFC222PFR110kC310u2{ucharj,k;for(j=0;ji;j++)for(k=0;k200;k++);}ucharcodetable_du[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0x7f8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff};voidmain(){disnum=16;wela=0;while(1){P3=0xf0;temp=P3;temp=temp&0xf0;if(temp!=0xf0){delay(10);if(temp!=0xf0){temp=P3;temp=temp|0x0f;P3=temp;key=P3;switch(key){case0xee:disnum=0;3break;case0xde:disnum=1;break;case0xbe:disnum=2;break;case0x7e:disnum=3;break;case0xed:disnum=4;break;case0xdd:disnum=5;break;case0xbd:disnum=6;break;case0x7d:disnum=7;break;case0xeb:disnum=8;break;case0xdb:disnum=9;break;case0xbb:disnum=10;break;case0x7b:disnum=11;break;case0xe7:disnum=12;break;case0xd7:disnum=13;break;case0xb7:disnum=14;break;case0x77:disnum=15;4break;}}}P0=table_du[disnum];}}3.电路图仿真效果当按下键盘时,所显示的效果如图3-1至图3-4图3-1:当按下K0键时,数码管显示数字‘0’P2.6P2.7XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435P0.5/AD534P0.6/AD633P0.7/AD732P1.0/T21P1.1/T2EX2P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C52K0K1K2K3K4K5K6K7K8K9KAKBKCKDKEKFX1C122PFC222PFR110kC310u5图3-2:当按下K4键时,数码管显示数字‘4’图3-3:当按下K8键时,数码管显示数字‘8’P2.6P2.7XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435P0.5/AD534P0.6/AD633P0.7/AD732P1.0/T21P1.1/T2EX2P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C52K0K1K2K3K4K5K6K7K8K9KAKBKCKDKEKFX1C122PFC222PFR110kC310uP2.6P2.7XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435P0.5/AD534P0.6/AD633P0.7/AD732P1.0/T21P1.1/T2EX2P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C52K0K1K2K3K4K5K6K7K8K9KAKBKCKDKEKFX1C122PFC222PFR110kC310u6图3-4:当按下KF键时,数码管显示数字‘F’5.总结电路设计方面,根据书本上还是课堂上老师所讲的知识,很快设计出来此仿真电路。软件设计方面,我感觉到在编写循环嵌套程序时非常容易出错,需要反复的查错和耐心的调试。我虽然能够编写出程序,其可读性却有待于提高。经过这次仿真设计,我对51系统的单片机内部构造的了解认识有了一定程度的提高。我体会到做设计是一项细致的工作,必须要投入时间及精力,要有耐心有韧性。我相信这几次的仿真设计会为我以后的发展打下一定的基础,我会更加努力,争取自己在单片机的开发上有更深层次的提高,与此同时经过此次仿真,锻炼了团队协作能力。P2.6P2.7XTAL218XTAL119ALE30EA31PSEN29RST9P0.0/AD039P0.1/AD138P0.2/AD237P0.3/AD336P0.4/AD435P0.5/AD534P0.6/AD633P0.7/AD732P1.0/T21P1.1/T2EX2P1.23P1.34P1.45P1.56P1.67P1.78P3.0/RXD10P3.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.7/RD17P3.6/WR16P3.5/T115P2.7/A1528P2.0/A821P2.1/A922P2.2/A1023P2.3/A1124P2.4/A1225P2.5/A1326P2.6/A1427U1AT89C52K0K1K2K3K4K5K6K7K8K9KAKBKCKDKEKFX1C122PFC222PFR110kC310u7
本文标题:基于单片机4X4矩阵键盘控制数码管显示的Proteus仿真
链接地址:https://www.777doc.com/doc-6442023 .html