这个1602显示有点怪怪的
1602.zip
(5.42 KB)
怎么显示这样
#include <REG51.H>
void delay(void);
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P2^2;
void start(void);
void delay1ms(int i);
void writecom(char i);
void writedata(char i);
int main(void)
{
char lcddata1[16]="I LOVE YOU GXQ !";
char lcddata2[16]="2013 3 22 ";
int i;
start();
writecom(0x80);
for(i=0;i<16;i++)
{
writedata(lcddata1[i]);
}
writecom(0x80+0x40);
for(i=0;i<16;i++)
{
writedata(lcddata2[i]);
}
while(1);
}
void start(void)
{
delay1ms(15);
writecom(0x38);
delay1ms(5);
writecom(0x38);
delay1ms(5);
writecom(0x38);
writecom(0x38);
writecom(8);
writecom(1);
writecom(6);
writecom(0x0c);
}
void delay1ms(int i)
{ int j;
for(i;i>0;--i)
for(j=100;j>0;--j);
}
void writecom(char i)
{
E=0;
RS=0;
RW=0;
P1=i;
delay1ms(5);
E=1;
delay1ms(1);
}
void writedata(char i)
{ E=0;
RS=1;
RW=0;
E=1;
P1=i;
delay1ms(5);
E=0;
}