12/13/2015

Interfacing LCD with PIC 16F877A Microcontroller

In this tutorial we will see how to interface LCD 16x2 with PIC 16F877A. It is an inevitable part used in all embedded  project. If you will learn it properly then you can easily design embedded project. LCD 16x2 display 2 lines with 16 characters. It can display all the letters, alphabet, mathematical symbols, Greek alphabet etc.  

Related post >> Blinking LED using PIC Microcontroller


Circuit Diagram 

VSS   --> This pin must be connected to the ground.
VDD --> This is positive supply (5v) voltage pin.
VEE --> Contrast adjustment pin
RS   --> Register selection
E     --> Enable
R/W -->  Read/write
D7,D6,D5,D4 --> Data pin




LCD may be connected to the PIC using either 4-bit or 8-bit. Here we are using 4-bit configuration. If an 8-bit bus is used then the remaining pin D1,D2,D3,D4 will be connect with the PIC PORD.D pin

Program:

Device 16F877A
XTAL 20  
ALL_DIGITAL TRUE
Declare LCD_DTPIN PORTD.4
Declare LCD_RSPIN PORTD.2
Declare LCD_ENPIN PORTD.3
Declare LCD_INTERFACE 4
Declare lcd_line 2
Declare LCD_TYPE 0 
Output PORTD
initial:
Cls
Print At 1, 1," Hello World " '
DelayMS 100
GoTo initial
----------------------------------------------------------------------------
 Declare LCD_DTPIN PORTD.4 --> It is uesd for 4 line interface. If we used 8 line interface then we will write 'Declare LCD_DTPIN PORTD.0' 

Declare LCD_RSPIN PORTD.2 --> It tells the compiler that the LCD's RS line will attach to PORTD.2 

Declare LCD_ENPIN PORTD.3--> It tells the compiler that LCD's enable pin will attach to PORTD.3 

Declare LCD_INTERFACE 4  -->Inform the compiler that it is 4 line interface. For 8-line we will write 'Declare LCD_INTERFACE 8. 

Declare lcd_line 2 --> Inform the compiler that the LCD's have 2 line.

Declare LCD_TYPE 0 --> Imform the compiler that it is alpha type LCD.
The remaining command we have discussed in our previous tutorial.

Diagram Of Final Output

                    Previous<<       >>Next

                                                   

No comments:

Post a Comment

Interfacing LCD With Arduino Microcontroller

In this tutorial we are going to  interface a  Liquid Crystal Display (LCD)  with Arduino Microcontroller .  Liquid Crystal Display are us...