In this tutorial , i will show how to make a Scrolling Display using LCD and PIC18F2550 .
Generally LCD display has 16 pins . 16x2 means the display has 12 columns and 2 rows .
The picture given below shows about rows and columns .
Lcd_Cmd(_LCD_SHIFT_RIGHT);
The picture given below discuss about each pin .
Proteus Project :
Now we are going to create a new project in Proteus and follow instructions given below :
According to instruction pick from library 'pic18f2550' , crystal, 22pf capacitor, 5Kohm variable resistor ,power and ground. For lcd display please type "LM016L" on keywords .
In this tutorial we will use 4 data pin [D4-D7] .Now complete the circuit as given below :
We have completed the circuit .Now we need the source hex file .So create a new project in MikroC and follow the instructions:
MikroC Source Code :
Required MikroC LCD Library Functions :
1.Lcd_Init : Initializes Lcd module.
2.Lcd_Out : Prints text on Lcd starting from specified position. Both string variables and literals can be passed as a text.
Parameters :
row:
starting position row numbercolumn:
starting position column numbertext:
text to be written
3.Lcd_Cmd : Sends command to Lcd.
a) Lcd_Cmd(_LCD_SHIFT_RIGHT) :This function is used for shifting on the right hand side .
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Lcd_Cmd(_LCD_SHIFT_RIGHT);
b) Lcd_Cmd(_LCD_SHIFT_LEFT) :This function is used for shifting on the left hand side.
c) Lcd_Cmd(_LCD_CURSOR_OFF) : This function is used for setting the cursor off .
d) Lcd_Cmd(_LCD_CLEAR) :To Clear the lcd .
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Source Code :
//
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB2_bit;
sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;
// End LCD module connections
char txt1[]=" Moving Right";
char txt2[]=" Moving Left";
int i=0,j=0;
void main() {
ADCON1=0x0F;
CMCON=7;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
while(1){
for(i=0;i<20;i++){
Lcd_Out(1,1,txt1);
Lcd_Cmd(_LCD_SHIFT_RIGHT);
delay_ms(200);
}
Lcd_Cmd(_LCD_CLEAR);
for(j=0;j<20;j++){
Lcd_Out(2,1,txt2);
Lcd_Cmd(_LCD_SHIFT_LEFT);
delay_ms(200);
}
}
}
//////////////////////////////////////////////////////
Now create a hex file with MikroC .Please follow the instructions :
Now go to the hardware and make double click on the Microcontroller .Please follow the instructions: