printing a word on lcd c code

printing a word on lcd c code

Posted in: embedded by Amanyire Maylean Patrick 2014-11-29 at 18:03:48


#include

sbit en = P3^2;
sbit rs = P3^0;
sbit rw = P3^1;

void init();
void enable();
void delay();
void setline(int );

void main(){

char msg [] ="Welcome";

char sec [] ="Maylean";
char *p;
char *s;

int j,i;


while(1){

init();

for(i=1;i<3;i++){
setline(i);

p=&msg;
s=&sec;

for(j=0;j<8;j++){
if(i==1){
P2= *p++;
}

else{
P2=*s++;

}
enable();

}


}

}


}

void init(){
rs=0;
rw=0;
en=0;
P2 = 0x38;
enable();
P2= 0x0F;
enable();
enable();

P2= 0x1c;
enable();
enable();
P2= 0x01;

enable();


}


void enable(){
en = 1;
delay();
en = 0;
delay();
}

void delay(){

int i;
for(i=0;i<2000;i++);

}

void setline(int ln){
if(ln==1){
rs=0;
rw=0;
P2=0x80;
enable();
rs=1;}

else {
rs=0;
rw=0;
P2=0xC4;
enable();
enable();
rs=1;


}

/* rw=0;
rs=0;//command
P2=0x80;
enable();
enable();
rs=1;//data*/

}










Search

Leave a comment

Fields with * are required
Your email address will not be displayed
2 + 5 =