这个是用1602写的程序,已经调试。用其他的液晶无法显示,只能用1602。
希望对你有帮助。
#include
#define uchar unsigned char
#define uint unsigned int
sbit rs=P3^5;
sbit lcden=P3^4;
sbit dula=P2^6;
sbit wela=P2^7;
sbit rw=P3^6;
uchar table1[]="hello world";
uchar table2[]="hello world";
void delay(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=10;b>0;b--);
}
void delay1(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=100;b>0;b--);
}
void write_com(uchar com)
{
P0=com;
rs=0;
rw = 0;
lcden=0;
delay(10);
lcden=1;
delay(10);
lcden=0;
}
void write_date(uchar date)
{
P0=date;
rs=1;
rw = 0;
lcden=0;
delay(10);
lcden=1;
delay(10);
lcden=0;
}
void init()
{
dula=0;
wela=0;
write_com(0x38);
delay(20);
write_com(0x0f);
delay(20);
write_com(0x06);
delay(20);
write_com(0x01);
delay(20);
}
void main()
{
uchar a;
init();
write_com(0x80+17);
delay(20);
for(a=0;a<9;a++)
{
write_date(table1[a]);
delay(20);
}
write_com(0xc0+17);
delay(50);
for(a=0;a<11;a++)
{
write_date(table2[a]);
delay(40);
}
for(a=0;a<11;a++)
{
write_com(0x18);
delay1(200);
}
while(1);
}
printf("hello world");
用什么点阵输出还是液晶呀