Skip to main content

LCD Interfacing with PIC Using XC8

In this tutorial, we are going to teach how to use an LCD display with an 8-bit PIC microcontroller. We will give you a powerful LCD library and explain how to use it in your microcontroller in this tutorial. We will do examples on the PIC16F628A microcontroller but you can do small changes to use it in your projects. Let’s get started to make LCD Interfacing.

We will make 3 projects using our library. These are;

  1. Writing Strings to LCD Display
  2. Shifting Strings and Toggling LCD Display
  3. Writing Numbers to LCD Display

With these projects, you will make what you want with LCD.

16×2 LCD Display

This display is a very basic module that is shown below which uses in very basic electronics projects and products. Pin connections of LCD display which we use areas in the picture below. Be sure that pin orientations are is same, or else you may burn your LCD display. If the pins are not the same, you need to correct the circuit for your LCD display.

16x2 LCD Display
16×2 LCD Display

We are going to use our LCD library. You can read a post about this library which we wrote in the link below.

Circuit Schematic

We will use the circuit below for all 4 projects.

LCD circuit for PIC16F628A microcontroller.
LCD Circuit

Configuration File

In this file, we add the configuration of fuses, and the definition of the oscillator, and include statements. This file is important because of LCD library needs this file and included libraries. Create config.h file in Header Files and copy-paste the code below. If your microcontroller is different edit configuration fuses.

Project 1

In this project, we are going to write “Trion Projects” for the first line and “LCD Interfacing” for the second line. You can print strings in 2 options. You can see options in the code.

LCD interfacing with PIC microcontroller.
LCD Interfacing

Project 2

Now let’s shift the string and toggle the LCD display. While printing strings we can center it. To center it we need to write 0 to LCDPrintString’s third parameter.

LCD Display Shifting And Toggling

Project 3

In our third project, we are going to print integer numbers on the LCD display. For this, we need to include stdio.h library. We included it in the config.h file.

LCD Display Variable Number

In this tutorial project, we teach how to use an LCD display with a PIC microcontroller. We hope this will be helpful. If you have some questions write in the comments below. Stay healthy and see you in the next tutorials.


Popular posts from this blog

Ultrasonic Sensor HC-SR04 With PIC Microcontroller

How Ultrasonic Sensor Works An ultrasonic sensor is a very useful sensor that measures distances with sounds. We used the PIC16F628A microcontroller for this project. This microcontroller has TMR1 which we are going to use. We need 2 I/O pins for TRIG and ECHO pins. For showing distance, we used an LCD. For more information about the LCD library and usage click the button below. LCD Interfacing with PIC Using XC8

How to Make Blink LED with PIC16F628A

How to Make Blink LED With PIC16F628A In this project tutorial, we are going to make blink-led projects with a pic microcontroller. After you read this tutorial you can build a PIC microcontroller project with XC8 on MPLAB IDE. We are going to make 3 different blinking projects. These projects are basic. Just learn how to make a basic project with a PIC microcontroller. You can see below which projects we are going to make; Blinking LED with 1s delay, LED with button, Blinking LED with a button.

How To Make Android App To Connect Arduino via Bluetooth

In this project, we are going to make an Android App that will connect with Arduino Nano via the HC-05 Bluetooth module. This app will control the LED, and motor, and read the temperature-humidity of the environment. We will use a free MIT App Inventor website for building apps via blocks. We will give all the project files for this project. If you are ready let’s get started. Schematic Firstly we made an example circuit to make bidirectional communication. You can see in the picture below which components we use. The main component is Arduino Nano which controls the system. We connect the red LED to the D2 pin. We use the L293D motor driver to control the DC motor. We added AHT10 to get temperature and humidity from the environment. Finally, we added HC-05 to communicate with the Android App. Circuit Schematic Android App We made an Android App via MIT App Inventor which is easy to make basic apps. This app will get and send data via Bluetooth. Let’s start to explain what we did. App