1、4 程序设计内容(1) 44行列式键盘识别技术:有关这方面内容前面已经讨论过,这里不再重复。(2) 8位数码显示,初始化时,显示“P”,接着输入最大6位数的密码,当密码输入完后,按下确认键,进行密码比较,然后给出相应的信息。在输入密码过程中,显示器只显示“8.”。当数字输入超过6个时,给出报警信息。在密码输入过程中,若输入错误,可以利用“DEL”键删除刚才输入的错误的数字。(3) 44行列式键盘的按键功能分布图如图4.33.2所示:789456123DelEnter图4.33.25 C语言源程序#include unsigned char ps=1,2,3,4,5;unsigned char
2、code dispbit=0xfe,0xfd,0xfb,0xf7, 0xef,0xdf,0xbf,0x7f;unsigned char code dispcode=0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07,0x7f,0x6f, 0x77,0x7c,0x39,0x5e,0x79,0x71, 0x00,0x40,0x73,0xff;unsigned char dispbuf8=18,16,16,16,16,16,16,16;unsigned char dispcount;unsigned char flashcount;unsigned char temp;
3、unsigned char key;unsigned char keycount;unsigned char pslen=5;unsigned char getps6;bit keyoverflag;bit errorflag;bit rightflag;unsigned int second3;unsigned int aa,bb;unsigned int cc;bit okflag;bit alarmflag;bit hibitflag;unsigned char oka,okb;void main(void) unsigned char i,j; TMOD=0x01; TH0=(6553
4、6-500)/256; TL0=(65536-500)%256; TR0=1; ET0=1; EA=1; while(1) P3=0xff; P3_4=0; temp=P3; temp=temp & 0x0f; if (temp!=0x0f) for(i=10;i0;i-) for(j=248;jj-); temp=P3; temp=temp & if (temp! temp=P3; temp=temp & switch(temp) case 0x0e: key=7; break; case 0x0d: key=8; case 0x0b: key=9; case 0x07: key=10; P
5、1_1=P1_1; if(key=0) & (key10) if(keycount keycount=6; keyoverflag=1;/key overflow else if(key=12)/delete key if(keycount0) keycount-; getpskeycount=0; dispbufkeycount+2=16; else keyoverflag=1; else if(key=15)/enter key if(keycount!=pslen) errorflag=1; rightflag=0; second3=0; else for(i=0;ikeycount;i+) if(getpsi!=psi) i=keycount; errorflag=1; rightflag=0; second3=0; goto a; errorflag=0; rightflag=1; i=keycount; while(temp! temp=P3; temp=temp & keyoverflag=0;/? P3_5=0; key=4; key=5; key=6; key=11; goto a4;a4: P3_6=0; key=1; key=2; key=3; key=12;=p
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2