Write a program to display a ship and rocket on LCD.


#include<8051.h>
void lcd_init();
void lcd_cmd(unsigned char d);
void display(unsigned char d);
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 a1[]={0,4,6,4,31,14,0,0};
unsigned char a2[]={4,4,31,4,4,4,10,17};
void custom(unsigned char *p,unsigned char n,unsigned char x)
{
unsigned int i;
lcd_cmd(64+n*8);
for(i=0;i<=7;i++)
{
display(p[i]);
}
lcd_cmd(0x02);
lcd_cmd(x);
display(n);
}
void main()
{
lcd_init();
custom(a1,0,0×80);
custom(a2,1,0×81);
}

Add Comment