|
#include <reg51.h>
#include <intrins.h>
sbit DB=P0;
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P2^2;
void delay(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_dat(unsigned char dat)
{
RW=0;RS=1;
DB=dat;
delay(5);
E=1;
delay(5);
E=0;
}
void write_com(unsigned char com)
{
RW=0;RS=0;
DB=com;
delay(5);
E=1;
delay(5);
E=0;
}
void lcd_1602init()
{
RW=0;
E=0;
write_com(0x3c);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void write_sfm(unsigned char add,unsigned char date)
{
unsigned char shi,ge;
shi=date/10;
ge=date%10;
write_com(0x80+add);
write_dat(0x30+shi);
write_dat(0x30+ge);
}
void main()
{
lcd_1602init();
while(1)
{
write_com(0xc0);
write_dat('2');
}
}
|
|