單片機(jī)LCD1602液晶顯示
程序:#include
#define uchar unsigned char
#define uint unsigned int
sbit LCDRS=P3^0;
sbit LCDR_W=P3^1;
sbit LCDE=P3^2;
uchar num[]="Li Junxuan ";
uchar num1[]="playup!";
void delay(uchar z)
{
int i,j;
for(i=0;i
}
void write_com(uchar com)
{
LCDRS=0;
P2=com;
delay(5);
LCDR_W=0;
LCDE=1;
delay(5);
LCDE=0;
}
void write_dat(uchar dat)
{
LCDRS=1;
P2=dat;
delay(5);
LCDR_W=0;
LCDE=1;
delay(5);
LCDE=0;
}
void main()
{
int x,y;
LCDE=0;
write_com(0x3c);
write_com(0x14);
write_com(0x0f);
for(x=0;x<10;x++)
{
write_dat(num[x]);}
write_com(0x80+0x40);
for(y=0;y<8;y++)
{
write_dat(num1[y]);
}
while(1);
}
評(píng)論