欢迎来到天天文库
浏览记录
ID:51666420
大小:66.50 KB
页数:12页
时间:2020-03-14
《书写点阵源程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#defineuintunsignedint#defineucharunsignedchar#includesbitin=P1^0;//光电笔输入端口sbitkey_dian=P3^4;//"点亮"功能sbitkey_hua=P3^5;//"划亮"功能sbitkey_fan=P3^6;//"反显"功能sbitkey_ca=P3^7;//"笔画擦除"功能sbitRS=P1^7;sbitRW=P1^6;sbitE=P1^5;sbitLCD1602=P1^4
2、;#defineLCDDataP2//液晶数据端口uchari;charH,L;uintdataZ[16];voidzuobiao(void);voidxianshi(void);voiddelay3ms(void);voiddelay1ms(void);voidsaomiao(void);voiddelay8ms(void);voiddelay500us(void);voiddelay50us(void);voiddianliang(void);voidhualiang(void);voidsaomiao_
3、ca(void);voidWriteCommand(unsignedcharc);voidWriteData(unsignedcharc);voidInitLcd();voidDelay5ms(void);//主函数main(){InitLcd();WriteCommand(0x82);WriteData('T');WriteData('i');WriteData('a');WriteData('n');WriteData('');WriteData('H');WriteData('u');WriteData
4、('a');WriteData('');WriteData('B');WriteData('e');WriteData('i');WriteCommand(0x82+0x40);WriteData('1');WriteData('1');WriteData('0');WriteData('3');WriteData('2');WriteData('4');WriteData('0');WriteData('1');WriteData('0');WriteData('0');WriteData('3');whi
5、le(1){if(!key_dian){delay8ms();//按键延时去抖if(!key_dian){dianliang();}}if(!key_hua){delay8ms();//按键延时去抖if(!key_hua){hualiang();}WriteCommand(0x01);//显示清屏}}}/////////////////////////////////////////////////////////////////////////////////////////////////////////
6、////////////////点亮模式子程序voiddianliang(void){WriteCommand(0x01);//显示清屏WriteCommand(0x84);WriteData('D');WriteData('i');WriteData('a');WriteData('n');WriteData('L');WriteData('i');WriteData('a');WriteData('n');WriteData('g');WriteCommand(0x80+0X40);WriteData('
7、Z');WriteData('u');WriteData('o');WriteData('B');WriteData('i');WriteData('a');WriteData('o');WriteData('');WriteData(':');WriteData('H');WriteData('');WriteData('');WriteData('');WriteData('L');WriteData('');WriteData('');while(1){saomiao();P0=i;WriteComma
8、nd(0x80+0X40+0x0a);WriteData(48+(H/10));WriteData(48+(H%10));if(!key_dian){charn;delay8ms();//按键延时去抖if(!key_dian){for(n=0;n<16;n++){Z[n]=0;}WriteCommand(0x01);//显示清屏break;}}WriteCommand(0x80+0X40+0x0e)
此文档下载收益归作者所有