#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
void delayms(uchar a)
{uchar i,j;
for(i=a;i>0;i--)
for(j=110;j>0;j--);
}
//1602pin initial
sbit lcde=P2^7;
sbit rs=P2^6;
sbit wr=P2^5;
//1602wirte a,com
void writecom(uchar a)
{ uchar tem;
tem=a;
rs=0;
P0=tem;
delayms(5);
lcde=1;
delayms(5);
lcde=0;
}
//1602data
void writedata1(uchar d)
{ uchar tem;
tem=d;
rs=1;
P0=tem;
delayms(5);
lcde=1;
delayms(5);
lcde=0;
}
//1602initial
void lcdinitial()
{wr=0;
lcde=0;
writecom(0x38);
writecom(0x0c);
writecom(0x06);
writecom(0x01);
}
sbit l1=P0^0;
void main()
{ lcdinitial();
writecom(0x80+5);
delayms(10);
writedata1(0x30+2);
while(1);
} |