

RS (Register Selection) to PORTC PIN 6 of PIC controller.VSS and PIN5 or RW (Read/Write) are commonly to ground.The connections which are done for LCD are given below: To connect we need to define one of Port Pins as as output and we need to assign individual pins required for interfacing LCD display. If we need to display a group of characters then the string function can be used.

Once the cursor is set we can write a character to its position by using this function. Lcd_Set_Cursor:Īs we are 16X2 type LCD display we need to instruct the LCD to set its cursor with preferred location by using this function. This function clears the LCD screen and can be used inside loops to clear the appearance of previous data. We need to call this function once in main program. This function helps to initialize and start the working LCD. So let us build and discuss some important functions inside lcd.h header file Init_LCD(): Similarly we need lcd.h header file to handle all LCD related functions. In previous Arduino Projects we have seen we need LiquidCrystal library or header file to handle or initialize function related to LCD. So without spending much time further on discussing about LCD in this project we will continue our configuration of PIC controller required for interfacing LCD. Pin 16 (CATHODE/LEDK/-ve pin of the LED): This pin is connected to GND. Pin15 (ANODE/LEDA/+ve pin of the LED): This pin is connected to +5V In 4-wire mode, only four pins are connected to the microcontroller unit like 0 to 3, whereas in 8-wire mode, 8-pins are connected to microcontroller unit like 0 to 7. These pins are connected in two-wire modes like 4-wire mode and 8-wire mode. Pins 7-14 (Data Pins/D0……D7): These pins are used to send data to the display. Pin 6 (Enable(E)): This pin should be held high to execute Read/Write process, and it is connected to the microcontroller unit & constantly held high. Pin5 (Read/Write(RW)): This pin toggles the display among the read or writes operation, and it is connected to a microcontroller unit pin to get either 0 or 1 (0 = Write Operation, and 1 = Read Operation). Pin4 (RS/Register Select/Control Pin): This pin toggles among command or data register, used to connect a microcontroller unit pin and obtains either 0 or 1(0 = data mode, and 1 = command mode). Pin3 (V0/VEE/Control Pin): This pin regulates the difference of the display, used to connect a changeable POT that can supply 0 to 5V. Pin2 (VCC/VDD/Source Pin): This is the voltage supply pin of the display, used to connect the supply pin of the power source. Pin1 (VSS/Ground): This is a GND pin of display, used to connect the GND terminal of the microcontroller unit or power source. LCD 16×2 Pin Diagram The 16×2 LCD pinout is shown below. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS&VDD or GND&+5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown), and 3 control pins (RS&RW&E). One can power or leave the back light pins. In 16×2 LCD there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins.

#Mplab xc8 lcd h how to#
In previous tutorials we have seen the how to configure and use the Timers in PIC controller and Timer1 in PIC Controller with simple LED blinking program. In this project we are going to Interface 16X2 LCD (Liquid Crystal Display) with our PIC Controller.

This tutorial is in continuation with our learning for PIC Microcontroller PIC16F877A.
