Experiment No 6

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

EXPERIMENT NO.

6
TITLE:
INTERFACING OF LCD TO PIC MICROCONTROLLER

AIM:
To interface the lcd to pic microcontroller.

THEORY:

Functions for Interfacing LCD with PIC Microcontroller:


To make things easier we have made a small library that could make things easy while
using this LCD with our PIC16F877A. The header file "MyLCD.h" is given here for
download, which contains all the necessary function to drive the LCD using PIC
MCU. Library code is well explained by comment lines but if you still have doubts reach us
through the comment section. Also check this article for Basic LCD working and its
Pinouts. Note: It is always recommended to know what is actually happening inside your
header file because it will help you in debugging or while changing the MCU.Now, there
are two ways to add this code into your program. You can either copy all the above lines
of code in MyLCD.h and paste them before the void main(). Or you can download the
header file using the link and add them to the header file of your project (#include "
MyLCD.h ";). This can be done by right clicking on the header file and selecting Add
existing Item and browsing to this header file.Here I have copied and pasted the header
file code into my main C file. So if you are using our code, then you don’t need to
download and add the header file into your program, just use the complete Code given at
the end of this Tutorial. Also note that this library will only support PIC16F series PIC
Microcontroller.

Here I am explaining each function inside our header file below:


void Lcd_Start(): This function should be the first function that has to be called to start
working with our LCD. We should call this function only once to avoid lag in the program.
Lcd_Clear(): This function clears the LCD screen and can be used inside loops to clear the
appearance of previous data.
void Lcd_Set_Cursor(x pos, y pos): Once started, our LCD is ready to take commands, we
can instruct the LCD to set its cursor in you preferred location by using this function.
void Lcd_Print_Char(char data)  : Once the cursor is set we can write a character to its
position by simple calling this function.
void Lcd_Print_String(char *a): If a group of characters is to be displayed, then the string
function can be used.
Circuit Diagram and Testing:
Below is the circuit diagram for Interfacing 16x2 LCD with PIC Microcontroller
CONCLUSION:

...........................................................................................................................................................
.........
...........................................................................................................................................................
...........................................................................................................................................................
..................

You might also like