Here we are going to create a Scrolling Message on an LCD, which is very easy to achieve given the rich set of Library functions in MikroC. Lets get started with the program.
MikroC Code:
/**********************************
Project Name :
Scrolling display with LCD
Author : Promise
Description :
This project demonstrate how to Make scrolling Message on an LCD
Test configuration:
MCU: PIC 16F877A
Oscillator: XT 8.0000 MHz, 8.0000 MHz Crystal
***********************************/
// Lcd pinout settings
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
char txt[] = "WELCOME TO OUR..." ;
char txt1[] = "BLOG!!!" ;
char txt2[] = "www.mechatronicsandyou.blogspot.com" ;
void main() {
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,txt); // output display
Lcd_Out(2,6,txt1);
delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR); // Cursor off
Lcd_Out(1,1,txt2); // output display
delay_ms(500);
while(1){ //endless loop
Lcd_Cmd(_LCD_SHIFT_LEFT); // shift display to left
delay_ms(100);
}
}
Proteus Schematic:
| Scrolling display with LCD in 4 bits mode |
