How to scrolling Lcd display use PIC Microcontroller and Mikro C
In this tutorial I will show you how to interface LCD with PIC microcontroller. You can watch the video and read the written tutorial below.
In this tutorial I am use PIC16F877A microcontroller & LM16X2 LCD display. PIC16F877A microcontroller. PIC16F877A microcontroller 8KB flash program memory & 256 Byte EEPROM memory.
LM 16X2 LCD Display it has16 pin connection.
In this tutorial I am use Mikro C Pro For PIC compiler for coding. Mikro C Pro For Pic provide a comfortable LCD library for LCD interfacing.
In this tutorial I am use PIC16F877A microcontroller & LM16X2 LCD display. PIC16F877A microcontroller. PIC16F877A microcontroller 8KB flash program memory & 256 Byte EEPROM memory.
LM 16X2 LCD Display
LCD means Liquid Crystal Display. In this project I am use LM 16X2 LCD Display. 16X2 means 16 column & 2 row in this display. There are 16*2 = 32 segment in this display. Each segment hold 8x2 dot patterns.
![]() |
LM16X2 LCD Display |
LM 16X2 LCD Display it has16 pin connection.
![]() |
PIN CONFIGURATION |
In this tutorial I am use Mikro C Pro For PIC compiler for coding. Mikro C Pro For Pic provide a comfortable LCD library for LCD interfacing.
MIKRO C PRO FOR PIC LCD Library
The mikroC PRO for PIC provides a library for communication with Lcds (with HD44780 compliant controllers) through the 4-bit interface.
External dependencies of LCD Library
The following variables must be defined in all projects using Lcd library. Lcd module connections example below.
// Lcd moude connection start
- sbit LCD_RS at RB0_bit ;
- sbit LCD_EN at RB1_bit ;
- sbit LCD_D4 at RB2_bit ;
- sbit LCD_D5 at RB3_bit ;
- sbit LCD_D6 at RB4_bit ;
- sbit LCD_D7 at RB5_bit ;
- sbit LCD_RS_Direction at TRISB0_bit ;
- sbit LCD_EN_Direction at TRISB1_bit ;
- sbit LCD_D4_Direction at TRISB2_bit ;
- sbit LCD_D5_Direction at TRISB3_bit ;
- sbit LCD_D6_Direction at TRISB4_bit ;
- sbit LCD_D7_Direction at TRISB5_bit ;
// Lcd module connection end
Lcd Library Routine
- Lcd_Init
- Lcd_Out
- Lcd_Out_Cp
- Lcd_Chr
- Lcd_Chr_Cp
- Lcd_Cmd
Circuit Diagram
![]() |
Circuit diagram of lcd module connection |
Mikro C code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lcd module connections | |
sbit LCD_RS at RB0_bit; | |
sbit LCD_EN at RB1_bit; | |
sbit LCD_D4 at RB2_bit; | |
sbit LCD_D5 at RB3_bit; | |
sbit LCD_D6 at RB4_bit; | |
sbit LCD_D7 at RB5_bit; | |
sbit LCD_RS_Direction at TRISB0_bit; | |
sbit LCD_EN_Direction at TRISB1_bit; | |
sbit LCD_D4_Direction at TRISB2_bit; | |
sbit LCD_D5_Direction at TRISB3_bit; | |
sbit LCD_D6_Direction at TRISB4_bit; | |
sbit LCD_D7_Direction at TRISB5_bit; | |
//end LCD module connection | |
char txt1[]= "WELCOME TO" ; | |
char txt2[] = "MINA TECHNOLOGY" ; | |
char i ; // loop variable | |
void main() { | |
Lcd_Init(); //initialize lcd module; | |
Lcd_Cmd(_LCD_CLEAR); //clear display | |
Lcd_Cmd(_LCD_CURSOR_OFF); // cursor off | |
Lcd_Out(1,3,txt1); //write text 1st row | |
Lcd_Out(2,1,txt2); //write text 2nd row | |
delay_ms(2000); | |
// Moving text | |
for(i=0;i<4;i++){ | |
Lcd_Cmd(_LCD_SHIFT_RIGHT); // text shift right | |
Delay_ms(500); // 500ms delay | |
} | |
while(1){ | |
for(i=0;i<8;i++){ | |
Lcd_Cmd(_LCD_SHIFT_LEFT); // text shift left | |
Delay_ms(500); | |
} | |
for(i=0;i<8;i++){ | |
Lcd_Cmd(_LCD_SHIFT_RIGHT); //text shift right | |
Delay_ms(500); | |
} | |
} | |
} |
Download
You can download Mickro C file here. click the download button.
![]() |
download |
No comments