C51_LCD1602顯示
#include
#define uchar unsigned char
#define uint unsigned int
sbit rs=P2^6;
sbit rw=P2^5;
sbit en=P2^7;
uchar shuma[10]={0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09};
// 0 1 2 3 4 5 6 7 8
void delay(uchar a)
{
uint i,j;
for(i=0;i<=110;i++)
for(j=0;j<=a;j++);
}
void write_com(uchar com)
{
rs=0;
rw=0;
en=0;
P0=com;
en=1;
delay(10);
en=0;
}
void write_dat(uchar dat)
{
rs=1;
rw=0;
en=0;
P0=dat;
en=1;
delay(10);
en=0;
}
void init_1602()
{
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main()
{
init_1602();
write_com(0x80+2);
write_dat(I);
write_com(0x80+4);
write_dat(a);
write_com(0x80+5);
write_dat(m);
write_com(0x80+7);
write_dat(i);
write_com(0x80+8);
write_dat(r);
write_com(0x80+9);
write_dat(o);
write_com(0x80+10);
write_dat(n);
write_com(0x80+12);
write_dat(m);
write_com(0x80+13);
write_dat(a);
write_com(0x80+14);
write_dat(n);
}
評(píng)論