// lcd header file
Lcd_Init();
Lcd_data(unsigned char,unsigned char );
Lcd_Display(unsigned char ,char const *);
set_delay(unsigned char ,unsigned int );
Lcd_Decimal(unsigned char ,unsigned int ,unsigned char );
Lcd_write(unsigned char ,unsigned char );
#define rs RD0
#define en RD1
#define dat_port PORTD
Lcd_Init()
{
Lcd_data(0x02,0);
Lcd_data(0x28,0);
Lcd_data(0x0c,0);
Lcd_data(0x06,0);
Lcd_data(0x01,0);
}
Lcd_data(unsigned char x,unsigned char y)
{
unsigned char a,b,t;
a= x & 0xf0;
b= (x<<4) & 0xf0;
t=dat_port & 0x0f;
dat_port=a|t;
rs=y;
en=1;set_delay(1,250);
en=0;
t=dat_port & 0x0f;
dat_port=b|t;
rs=y;
en=1;set_delay(1,250);
en=0;
}
Lcd_write(unsigned char x,unsigned char y)
{
Lcd_data(x,0);//command_mode
Lcd_data(y,1);//data_mode
}
Lcd_Display(unsigned char x,char const *y)
{
Lcd_data(x,0); //command mode
while(*y!='\0')Lcd_data(*y++,1); //data mode
}
Lcd_Decimal(unsigned char x,unsigned int y,unsigned char n)
{
Lcd_data(x,0);
unsigned int m=1;
while(n--)m=m*10;
while(m>1)
{
Lcd_data((y%m)/(m/10)+0x30 , 1);
m=m/10;
}
}
set_delay(unsigned char x,unsigned int y)
{
while(x--)while(y--);
}