I did what you suggest but it show different garbage value on lcd screen. code is below and I also attached picture of display.Already covered by MrChips and myself.
Code:
#include<stdio.h>
#include<reg51.h>
//sfr ldata=0xB0;
sbit en =P3^2;
sbit rw =P3^1;
sbit rs =P3^0;
int i,j;
int k;
void delay();
void lcdcmd (unsigned char );//lcd initialization command function prototype
void lcddata(unsigned char ); //lcd data funtion prototype
void lcdstring(unsigned char *);
char comm[]={0x01,0x02,0x06,0x0e,0x38};//lcd initialization
//char dat[]={"hafi1z"};// string to show on lcd
void main(void)
{
rs = 0;
rw=0;
en = 0;
for(i=0;i<5;i++)
{
P2 = comm[i];
en = 1;
delay();
en = 0;
delay();
lcddata("welcome"); //data function called
}
void lcddata(unsigned char a)// data funtion
{
rs=0;
rw=0;
en=0;
//ldata=value;
//for(k=0;k<8;k++)
// {
P2= a;//[k];
rs=1;
en=1;
delay();
en=0;
//}
}
void lcdstring( unsigned char *value)// string function
{
while(*value)
lcddata(*value++);
}
void delay() //delay function
{
for (j=0;j<300;j++)
for (k=0;k<=50;k++);
}
Attachments
-
209.1 KB Views: 13