《门禁系统源程序.pdf》由会员分享,可在线阅读,更多相关《门禁系统源程序.pdf(5页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、#include #include #defineDATAP0/1602 驱动端口sbit RS=P20;sbit RW=P21;sbit E=P22;sbit KA=P27;int Pre_KeyNo=16,KeyNo=16;void delayMs( int x);void Keys_Scan();void Busy()/LED 液晶是否忙碌DATA = 0 xff;RS = 0;RW = 1;while(DATA & 0 x80)E = 0;E = 1;E = 0;/LED 写指令程序void WriteCommand(unsigned char btCommand)Busy();RS
2、= 0;RW = 0;E = 1;DATA = btCommand;E = 0;/LED 写数据程序void WriteData(unsigned char btData)Busy();RS = 1;RW = 0;E = 1;DATA = btData;E = 0;/LED 清屏显示void Clear()WriteCommand(1);/LED 初始化void Init()WriteCommand(0 x0c); /开显示,无光标显示WriteCommand(0 x06); /文字不动,光标自动右移WriteCommand(0 x38); /设置显示模式:8 位 2 行 5x7 点阵Writ
3、eCommand(0 x40);/for(i=0;i40 x0f;switch(Tmp)case 1:KeyNo+=0; break;case 2:KeyNo+=4; break;case 4:KeyNo+=8; break;case 8:KeyNo+=12;void delayMs( int x)char t;while(x-)for(t=0;t120;t+);void main()int hang=0,c=0;int i,j=0;unsigned char tab12,tab112=1,1,1,1,1,1;unsigned char tab3=welcome to .;unsigned c
4、har tab4=alter password.;unsigned char tab5=OK;unsigned char tab6=NO;Init();loop1:Clear();i=0;KeyNo=16;while(1)WriteCommand(0 x80);for(c=0;c=0&KeyNo=9)tabi+=KeyNo;DisplayOne(1,i, *,0);/DisplayOne(0,i, KeyNo,1);if(KeyNo=14)while(P1!=0 xf0);goto loop1;if(KeyNo=11)KA=1;if(KeyNo=10)for(j=0;j6;j+)if(tabj!=tab1j)break;if(j=6)KA=0;for(j=0;j6;j+) tabj=0;while(P1!=0 xf0);goto loop1;if(KeyNo=12)i=0;WriteCommand(0 x80);for(c=0;c=0&KeyNo=9)tab1i+=KeyNo;DisplayOne(1,i, *,0);/ DisplayOne(0,i, KeyNo,1);while(P1!=0 xf0);if(KeyNo=13)goto loop1;KeyNo=16;while(P1!=0 xf0);delayMs(100);