欢迎来到天天文库
浏览记录
ID:61488381
大小:11.15 KB
页数:7页
时间:2021-02-05
《基于单片机的银行排队较好系统 c语言编程.docx》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#include#defineucharunsignedchar//宏定义#defineuintunsignedint//宏定义sbitk0=P2^3;//取号用的按键sbitk1=P2^4;//呼叫客户的按键1sbitk2=P2^5;//呼叫客户的按键2sbitk3=P2^6;//呼叫客户的按键3sbitk4=P2^7;//呼叫客户的按键4sbitbuzzer=P2^2;//蜂鸣器接口sbitrs1=P2^0;sbiten1=P2^1;sbitrs2=P3^0;sbiten2=P3^1;uintnum;//顾客所领
2、取的号码uintnum1;//服务人员所呼叫的号码ucharwindown;//窗口号uchari,t0;ucharcodetable2[]="";ucharcodetable1_1[]="NO.0000cometo";ucharcodetable1_2[]="0.window,please!";//用于液晶1初始化显示ucharcodetable2_1[]="HELLOW";ucharcodetable2_2[]="yournumber:";//用于液晶2初始化显示voidkeyscan();//按键检测voidwrite_orde
3、r1(ucharorder);//写指令函数液晶1voidwrite_dat1(uchardat);//写数据函数液晶1voidinit_lcd1();//液晶1初始化voidwrite_add1(ucharaddress,uchardat);//指定地址写入数据voiddisplay_lcd1(uintnum,uchar);//液晶1显示voidwrite_order2(ucharorder);//写指令函数液晶2voidwrite_dat2(uchardat);//写数据函数液晶2voidinit_lcd2();//液晶2初始化v
4、oidwrite_add2(ucharaddress,uchardat);//指定地址写入数据voiddisplay_lcd2(uintnum);//液晶2显示voiddelay(ucharz)//延时函数{uchari,j;for(i=z;i>0;i--)for(j=110;j>0;j--);}voidinit()//初始化{t0=0;windown=0;num=0;buzzer=0;TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=0;//定时
5、器0init_lcd2();init_lcd1();}voidmain(){init();while(1){keyscan();display_lcd1(num1,windown);display_lcd2(num);}}voidkeyscan()//按键检测{if(k0==0)//叫号按键检测{delay(10);//延时消抖if(k0==0)num++;//号码数加1while(!k0);delay(10);//延时消抖while(!k0);//按键松手检测}if(k1==0){delay(10);if(k1==0){if(num
6、17、3);delay(10);//延时消抖while(!k3);//按键松手检测}if(k4==0){delay(10);if(k4==0){if(num18、//写数据函数液晶1{rs1=1;en1=0;P0=dat;delay(1);en1=1;delay(1);en1=0;}voidinit_lcd1()//液晶1初始化{write_order1(0x38);write_
7、3);delay(10);//延时消抖while(!k3);//按键松手检测}if(k4==0){delay(10);if(k4==0){if(num18、//写数据函数液晶1{rs1=1;en1=0;P0=dat;delay(1);en1=1;delay(1);en1=0;}voidinit_lcd1()//液晶1初始化{write_order1(0x38);write_
8、//写数据函数液晶1{rs1=1;en1=0;P0=dat;delay(1);en1=1;delay(1);en1=0;}voidinit_lcd1()//液晶1初始化{write_order1(0x38);write_
此文档下载收益归作者所有