Write a program to display 2 names on LCD in 2 different rows and when we 1st switch the name on first row should be displayed,when we press 2nd switch the name on 2nd row should be displayed otherwise both the names should be displayed.


#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 $”};
unsigned char name1[]={“AALIYA $”};
void string(unsigned char *p)
{
while(*p!=’$’)
{
display(*p);
p++;
}
}
void main()
{
lcd_init();
while(1)
{
if(P0_0==0)
{
lcd_cmd(0x01);
lcd_cmd(0x80);
string(name);
delay(50000);
}
else
{
lcd_cmd(0x80);
string(name);
lcd_cmd(0xc0);
string(name1);
}
if(P0_1==0)
{
lcd_cmd(0x01);
lcd_cmd(0xc0);
string(name1);
delay(50000);
}
}
}

Add Comment