欢迎来到天天文库
浏览记录
ID:40519500
大小:28.00 KB
页数:3页
时间:2019-08-04
《51单片机和12864液晶显示实例——C语言》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#defineuncharunsignedchar#defineunintunsignedintsbitRS=P2^7;sbitRW=P2^6;sbitE=P2^5;voiddelay(unsignedintt){unsignedinti,j;for(i=0;i2、S=0;RW=0;E=1;P0=com;delay(5);E=0;delay(5);}voidwrite_date(unchardate){busy();RS=1;RW=0;E=1;P0=date;//delay(5);E=0;//delay(5);}voidinit(){delay(2000);write_com(0x30);//选择基本指令,选择8位数据流delay(5);write_com(0x0c);//开显示(无游标,不反白)delay(10);write_com(0x01);//清除显示,并且设定地址指针为003、Hdelay(500);write_com(0x06);//设定游标移动方向}voidsendaddr(uncharn,uncharm){switch(n){case1:write_com(0x80+m);break;case2:write_com(0x90+m);break;case3:write_com(0x88+m);break;case4:write_com(0x98+m);break;}}voiddisplay(uncharn,uncharm,unchar*s){sendaddr(n,m);while(*s>0)4、{write_date(*s);s++;delay(100);}}voidmain(){unchar*s;init();s="甲:“我来了”";display(1,0,s);s="乙:“热烈欢迎。";delay(10000);display(2,0,s);s="。。。热烈欢迎”";delay(10000);display(3,0,s);s="麻烦跟我去派出所";delay(10000);display(4,0,s);delay(10000);write_com(0x01);s="乙“为什么?”";delay(10000);5、display(1,0,s);s="我们发现你偷税漏税。。。";delay(10000);display(2,0,s);delay(10000);write_com(0x01);write_com(0x80);write_date(0x32);while(1);}
2、S=0;RW=0;E=1;P0=com;delay(5);E=0;delay(5);}voidwrite_date(unchardate){busy();RS=1;RW=0;E=1;P0=date;//delay(5);E=0;//delay(5);}voidinit(){delay(2000);write_com(0x30);//选择基本指令,选择8位数据流delay(5);write_com(0x0c);//开显示(无游标,不反白)delay(10);write_com(0x01);//清除显示,并且设定地址指针为00
3、Hdelay(500);write_com(0x06);//设定游标移动方向}voidsendaddr(uncharn,uncharm){switch(n){case1:write_com(0x80+m);break;case2:write_com(0x90+m);break;case3:write_com(0x88+m);break;case4:write_com(0x98+m);break;}}voiddisplay(uncharn,uncharm,unchar*s){sendaddr(n,m);while(*s>0)
4、{write_date(*s);s++;delay(100);}}voidmain(){unchar*s;init();s="甲:“我来了”";display(1,0,s);s="乙:“热烈欢迎。";delay(10000);display(2,0,s);s="。。。热烈欢迎”";delay(10000);display(3,0,s);s="麻烦跟我去派出所";delay(10000);display(4,0,s);delay(10000);write_com(0x01);s="乙“为什么?”";delay(10000);
5、display(1,0,s);s="我们发现你偷税漏税。。。";delay(10000);display(2,0,s);delay(10000);write_com(0x01);write_com(0x80);write_date(0x32);while(1);}
此文档下载收益归作者所有