Microcontroller › 8051 › Microcontroller › #include
June 9, 2014 at 9:58 pm
#11810
Participant
#include <reg51.h>
msDelay(unsigned int);
cmd(unsigned char); //LCD command code initialization
dat(unsigned char ); // LCD data code initialization
sbit regs=P2^6; //name the pin register select of the lcd
sbit enab=P2^7;
sbit rd=P2^5;
void LCD_write_string(unsigned char *str) //store address value of the string in pointer *str
{
unsigned char j = 0;
while (str[j] != 0)
{
dat(str[j]); // sending data on LCD byte by byte
msDelay(100);
j++;
}
return;
}
void main (void)
{
cmd(0x38);
msDelay(100);
cmd(0x0C);
msDelay(100);
cmd(0x01);
msDelay(100);
while(1)
{
LCD_write_string(“osama”);
msDelay(2000);
cmd(0x01);
msDelay(2000);
}
}
cmd(unsigned char value)
{
P1=value;
regs=0;
rd=0;
enab=0;
msDelay(500);
enab=1;
}
dat(unsigned char info)
{
P1=info;
regs=1;
rd=0;
enab=0;
msDelay(500);
enab=1;
}
msDelay(unsigned int tdelay)
{
unsigned int k,j;
for(k=0;k<=tdelay;k++)
for(j=0;j<=100;j++);
}
This is a code I used to test the LCD , it is not the code that I use in the project that I am working in but just to test the LCD ,but unfortunately this is not working 
