打印
[华山论剑]

基于51单片机运用液晶屏显示字符

[复制链接]
1076|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
快捷键CQ|  楼主 | 2022-4-24 17:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
基于51单片机运用液晶屏显示字符时出了些问题,编译什么的都没问题,但是就是液晶屏没动静,液晶屏是1602,求助,急急急,跪谢 #includesbit lcd_en= P2^7;sbit lcd_rs = P2^6;sbit lcd_rw =P2^5;sbit lcd_data = P0;#define unchar unsigned char#define uint unsigned intunchar code table[]={"baby ChenDan's"};unchar code table1[]={"birthday 0311"};unchar code table2[]={"Happy Birthday"};unchar code table3[]={"be happiness"};unchar num;void delay_10us(uint n) // 10微秒的延时子程序{ uint i,j; for(i=n;i>0;i--) for(j=2;j>0;j--); } void writecmd(char com){ delay_10us(5); lcd_rs=0; lcd_rw=0; lcd_data=com; delay_10us(5); lcd_en=1; delay_10us(5); lcd_en=0;}void writedata(char lcddata){ delay_10us(5); lcd_rs=1; lcd_rw=0; lcd_data=lcddata; delay_10us(5); lcd_en=0; delay_10us(5); lcd_en=1;}void lcdinit(){ writecmd(0x38); writecmd(0x08); writecmd(0x01); writecmd(0x0c); writecmd(0x06);}void main(){ lcdinit(); while(1) { writecmd(0x80); for(num=0;num<15;num++) { writedata(table[num]); delay_10us(50); } writecmd(0x80+0x40); for(num=0;num<16;num++) { writedata(table1[num]); delay_10us(50); } delay_10us(100); writecmd(0x01); writecmd(0x80); for(num=0;num<14;num++) { writedata(table2[num]); delay_10us(50); } writecmd(0x80+0x40); for(num=0;num<16;num++) { writedata(table3[num]); delay_10us(50); } delay_10us(100); writecmd(0x01); }}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

18

主题

31

帖子

0

粉丝