This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

scroll_text in LCD

#include<reg51.h>
#define lcd P2
#include<string.h>

sbit RS=P1^0;
sbit RW=P1^1;
sbit EN=P1^2;

void init_lcd(void);
void cmd_lcd(unsigned char);
void data_lcd(unsigned char);
void write_lcd(unsigned char);
void delay(unsigned char);

void main()
{ unsigned char str[20]="hello vector in",i=0,j=0,cnt=0;

j=strlen(str);

init_lcd();

for(i=0;i<=j;i++) {

data_lcd(str[i]); } while(1) { data_lcd(0x8f); for(i=0;i<strlen(str);i++) { cmd_lcd(0x18);

} i=0; }
}

void init_lcd(void)
{ cmd_lcd(0x30);//8 bit mode 5*7 pixel cmd_lcd(0x01);//clear the screen cmd_lcd(0x0c);//display on with cursor off cmd_lcd(0x06);//shift cursor right side cmd_lcd(0x8f);//cursor is in first position
}

void cmd_lcd(unsigned char ch)
{ RS=0; write_lcd(ch);
}

void write_lcd(unsigned char ch)
{ lcd= ch; RW=0; EN=1; delay(15); EN=0;
} void data_lcd(unsigned char ch)
{ RS=1; write_lcd(ch);
}

void delay(unsigned char ch)
{ int i,j; for(i=0;i<ch;i++) for(j=0;j<1275;j++);
}

Parents Reply Children