lcd很重要,很多地方要用它方便调试。在这里多专研一点有用。如使用光标的闪烁,移动改变特定位置字符等。
这里使用基本功能;静态显示。
#include
sbit rs=P2^4;
sbit rw=P2^5;
sbit e=P2^6;
unsigned char zm1[]="h---i---";
unsigned char zm2[]="qingnian";
void delay(unsigned t)
{
while(t--);
}
void write_com(unsigned char com)
{
e=0;
rs=0;
rw=0;
P0=com;
delay(50);
e=1;
delay(50);
e=0;
delay(50);
}
void write_data(unsigned char dat)
{
e=0;
rs=1;
rw=0;
P0=dat;
delay(50);
e=1;
delay(50);
e=0;
delay(50);
}
void start()
{
delay(200);
write_com(0x38);
delay(200);
write_com(0x38);
delay(200);
write_com(0x38);
write_com(0x38);
write_com(0x08);
write_com(0x01);
write_com(0x06);;
write_com(0x0c);
}
void main()
{
int j;
start();
write_com(0x80);
for(j=0;j<8;j++)
{
write_data(zm1[j]);
delay(200);
}
write_com(0x80+0x40);
for(j=0;j<8;j++)
{
write_data(zm2[j]);
delay(200);
}
while(1);LCD.zip
}
c编程:
阅读(300) | 评论(0) | 转发(0) |