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.

Comments

Popular posts from this blog

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.

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

DC Motor Speed Control With PIC16F628A

DC Motor Speed Control Simulation In this project, we will control the speed and direction of a DC motor using the PIC16F628A microcontroller. We will write the software in MPLAB IDE with the XC8 language that will send a PWM signal to L293D to control the motor. Finally, we will simulate it through the Proteus software. PWM (Pulse Width Modulation) You can get more information about the PWM signal from the link above. Now let’s examine the L293D motor driver.