#include<reg51.h>
sbit RS=P0^0;
sbit RW=P0^1;
sbit EN=P0^2;
#define ldata P1
void lcd_init();
void cmd(unsigned char c);
void dat(unsigned char c);
void delay(unsigned int i);
void main()
{
int p;
char arr[12]={'E','M','B','E','D','D','E','D',' ','L','A','B'};
lcd_init();
for(p=0;p<12;p++)
dat(arr[p]);
while(1);
}
void lcd_init()
{
cmd(0X01);
delay(10);
cmd(0X08);
delay(10);
cmd(0X0e);
delay(10);
cmd(0X38);
delay(10);
}
void cmd(unsigned char c)
{
int i;
ldata=c;
RS=0;
RW=0;
EN=1;
for(i=0;i<10;i++);
EN=0;
return;
}
void dat(unsigned char c)
{
int i;
ldata=c;
RS=1;
RW=0;
EN=1;
for(i=0;i<=10;i++);
EN=0;
return;
}
void delay(unsigned int b)
{
unsigned int i,j;
for(i=0;i<b;i++)
for(j=0;j<3000;j++);
}
No comments:
Post a Comment