LCD_string
Published Tuesday, 4 October 2011 by gk in#include <reg51.h>
sfr ldata=0x90;
sbit rs = P2^0;
sbit en = P2^1;
void init_lcd();
void cmd_lcd(unsigned char );
void dat_lcd(unsigned char );
void delay(unsigned int);
void wrt_lcd(unsigned *);
void init_lcd()
{
cmd_lcd(0x38);
cmd_lcd(0x0E);
cmd_lcd(0x80);
cmd_lcd(0x01);
}
void cmd_lcd(unsigned char a)
{
ldata = a;
rs = 0;
en = 1;
delay(200);
en = 0;
delay(100);
}
void dat_lcd(unsigned char a)
{
ldata = a;
rs = 1;
en = 1;
delay(200);
en = 0;
delay(100);
}
void delay(unsigned int val)
{
int b;
for(b=0;b<val;b++);
}
void main()
{
init_lcd();
wrt_lcd("hello gopal");
while(1);
}
void wrt_lcd(unsigned char *p)
{
while(*p!='\0')
{
dat_lcd(*p);
p++;
}
}
sfr ldata=0x90;
sbit rs = P2^0;
sbit en = P2^1;
void init_lcd();
void cmd_lcd(unsigned char );
void dat_lcd(unsigned char );
void delay(unsigned int);
void wrt_lcd(unsigned *);
void init_lcd()
{
cmd_lcd(0x38);
cmd_lcd(0x0E);
cmd_lcd(0x80);
cmd_lcd(0x01);
}
void cmd_lcd(unsigned char a)
{
ldata = a;
rs = 0;
en = 1;
delay(200);
en = 0;
delay(100);
}
void dat_lcd(unsigned char a)
{
ldata = a;
rs = 1;
en = 1;
delay(200);
en = 0;
delay(100);
}
void delay(unsigned int val)
{
int b;
for(b=0;b<val;b++);
}
void main()
{
init_lcd();
wrt_lcd("hello gopal");
while(1);
}
void wrt_lcd(unsigned char *p)
{
while(*p!='\0')
{
dat_lcd(*p);
p++;
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment