1602液晶顯示C語言編寫
#include
#define uchar unsigned char
#define uint unsigned int
sbit lcden=P3^7;
sbit led=P3^6;
sbit lcdrs=P3^5;
uchar num;
uchar code table[]="I LIKE MCU!";
void delay(uint i)
{
uchar j;
for(;i>0;i--)
for(j=110;j>0;j--);
}
void write_1602com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_1602(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init_1602()
{
lcden=0;
write_1602com(0x38);
write_1602com(0x0e);
write_1602com(0x06);
write_1602com(0x01);
write_1602com(0x80+0x10);
}
void main()
{
init_1602();
for(num=0;num<11;num++)
{
}
while(1);
}
評(píng)論