Write a program to display any name on LCD using string function and to shift the name right and left when we press the switches.


#include<8051.h>
void lcd_init();
void display(unsigned char d);
void lcd_cmd(unsigned char d);
void string(unsigned char *p);
void delay(unsigned int i)
{
while(i!=0)
{
i–;
}
}
void lcd_init()
{
lcd_cmd(0x38);
lcd_cmd(0x01);
lcd_cmd(0x0c);
}
void lcd_cmd(unsigned char d)
{
P1=d;
delay(300);
P3_3=0;
P3_4=1;
P3_4=0;
}
void display(unsigned char d)
{
P1=d;
delay(300);
P3_3=1;
P3_4=1;
P3_4=0;
}
unsigned char name[]={“AASHNA $”};
void string(unsigned char *p)
{
while(*p!=’$’)
{
display(*p);
p++;
}
}
void main()
{
lcd_init();
lcd_cmd(0x80);
string(name);
while(1)
{
if(P0_0==0)
{
lcd_cmd(0x01);
lcd_cmd(0x1e);
string(name);
delay(50000);
}
if(P0_1==0)
{
lcd_cmd(0x01);
lcd_cmd(0x81);
lcd_cmd(0x18);
string(name);
delay(50000);
}
}
}

Add Comment