程序如下:
#include<reg52.h>
sbit rs=P2^6;
sbit rw=P2^5;
sbit en=P2^7;
unsigned char table1[]={"LCD1602 check ok"};
unsigned char table2[]={"study up"};
void inital_lcd();
void lcd_display();
void delay_long(unsigned int uidelaylong);
void lcd_wcom(unsigned char com)
{
rs=0;
rw=0;
P0=com;
delay_long(5);
en=1;
en=0;
}
void lcd_wdat(unsigned char dat)
{
rs=1;
rw=0;
P0=dat;
delay_long(5);
en=1;
en=0;
}
void main()
{
inital_lcd();
while(1)
{
lcd_display();
delay_long(100);
}
}
void lcd_display()
{
unsigned char n,m;
//lcd_wcom(0x80);
for(m=0;m<16;m++)
{
lcd_wdat(table1[m]);
delay_long(10);
}
// lcd_wcom(0x80+0x44);
for(n=0;n<10;n++)
{
lcd_wdat(table2[n]);
delay_long(10);
}
}
void inital_lcd()
{
lcd_wcom(0x38);
lcd_wcom(0x0c);
lcd_wcom(0x06);
lcd_wcom(0x01);
}
void delay_long(unsigned int uidelaylong)
{
unsigned int i;
unsigned int j;
for(i=0;i<uidelaylong;i++)
{
for(j=0;j<500;j++)
{
;
}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>