char lcdbuffer[17] = {"Electro - tech "};
void msdelay(unsigned int time) // Function for creating delay in milliseconds.
{
unsigned i, j ;
for(i = 0; i < time; i++)
for(j = 0; j < 75; j++);
}
void lcd_cmd(unsigned char command) //Function to send command instruction to LCD
{
display_port = command;
rs = 0;
rw = 0;
e = 1;
msdelay(1);
e = 0;
}
void lcd_data(unsigned char disp_data) //Function to send display data to LCD
{
display_port = disp_data;
rs = 1;
rw = 0;
e = 1;
msdelay(1);
e = 0;
}
void Lcd_print(char* str)
{
while(*str != 0)
lcd_data(*str++);
}
void lcd_init() //Function to prepare the LCD and get it ready
{
msdelay(20);
lcd_cmd(0x38); // for using 2 lines and 5X7 matrix of LCD
msdelay(10);
lcd_cmd(0x0C); // turn display ON, cursor blinking
msdelay(10);
lcd_cmd(0x06); //clear screen
msdelay(10);
lcd_cmd(0x1); // bring cursor to position 1 of line 1
msdelay(10);
}
void rotateRight(void)
{
char temp, x;
temp = lcdbuffer[15];
for( x = 15;x >0 ;x--)
{
lcdbuffer[x] = lcdbuffer[x-1];
}
lcdbuffer[0]=temp;
lcdbuffer[16] = 0;
lcd_cmd(0x80);
Lcd_print(lcdbuffer);
msdelay(200);
}
void rotateleft(void)
{
char temp,x;
temp = lcdbuffer[0];
for( x = 0;x<15;x++)
{
lcdbuffer[x] = lcdbuffer[x+1];
}
lcdbuffer[15]=temp;
lcdbuffer[16] = 0;
lcd_cmd(0x80);
Lcd_print(lcdbuffer);
msdelay(200);
}
void main()
{
int i ;
lcd_init();
Lcd_print(lcdbuffer);
while(1)
{
msdelay(1000);
i = 16;
while(i--)
rotateleft(); // searching the null terminator in the sentence
msdelay(1000);
i=16;
while(i--)
rotateRight();
}
}