基于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); }}
|