Summary of Display temperature on Graphic Liquid Crystal Display using PIC16F877A Microcontroller
This article details a project displaying temperature readings via a bar graph on a Graphic LCD using a PIC16F877A microcontroller. The system utilizes an LM35 sensor to measure temperature, which is processed by the microcontroller and visualized as dynamic bars representing different temperature thresholds. The code is written in C using mikroC PRO for PIC and includes logic to adjust bar heights based on temperature ranges from 20°C to 145°C.
Parts used in the Display Temperature with Bar Graph on GLCD Project:
- PIC16F877A Microcontroller
- Graphic Liquid Crystal Display (GLCD) 128x64
- LM35 Temperature Sensor
- mikroC PRO for PIC V. 7.1.0 Compiler
- Proteus 8 Simulation Software
- C and Assembly Language Code Files
Hello everybody welcome back . Today I’m gonna tell how you can display temperature with bar graph on Graphic LCD using PIC microcontroller . The project is very simple to understand if you have concept of
Graphic LCD .The program in this project is written in C and Assembly level language & the compiler used to write the C code is mikroC PRO for PIC V. 7.1.0 .You can download complete project (C and Asm file with proteus8 file ) from this link temperature on GLCd .
Graphical Liquid Crystal (GLCD)
Graphical lcds are different from the ordinary alphanumeric lcds, like 16×1 16×2 16×4 20×1 20×2 etc. They (ordinary) can print only characters or custom made characters. They have a fixed size for displaying a character normally 5×7 or 5×8 matrix. Where as in graphical lcd we have 128×64=8192 dots each dot can be lit up as our wish or we can make pixels with 8 dots ie. 8192/8=1024 pixels. We can design a character in a size which we need. More over we can make a picture on a graphical LCD as well. you can learn more about this LCD on this link Graphic LCD
LM35 Temperature Sensor
The LM35 temperature sensor is a semiconductor sensor. It is available in integrated circuit (IC) form. It has 3 pins and the IC is as shown below.

VT = kT/q
Features of LM35:
- Calibrated directly in Celsius scale ( Centigrade)
- Linear +10 mV/0C scale factor
- 50C Ensured Accuracy (at 250C)
- Works for -550C to 1500C
- Operates in the range of 4V to 30V
- Less than 60µA design drain current
- Low impedance output, 0.1Ω for 1-mA load
- Low self heating, 0.80C in still air
Display temperature on Graphic Liquid Crystal Display using PIC16F877A Microcontroller (Code)
// Glcd module connections
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at RC0_bit;
sbit GLCD_CS2 at RC1_bit;
sbit GLCD_RS at RB3_bit;
sbit GLCD_RW at RB4_bit;
sbit GLCD_EN at RB5_bit;
sbit GLCD_RST at RE2_bit;
sbit GLCD_CS1_Direction at TRISC0_bit;
sbit GLCD_CS2_Direction at TRISC1_bit;
sbit GLCD_RS_Direction at TRISB3_bit;
sbit GLCD_RW_Direction at TRISB4_bit;
sbit GLCD_EN_Direction at TRISB5_bit;
sbit GLCD_RST_Direction at TRISE2_bit;
// End Glcd module connections
char txt[4];
unsigned tmp;
void main() {
Glcd_Init();
Glcd_Fill(0);
ADC_Init();
while(1){
tmp = ADC_Read(0);
tmp = tmp/2.05;
ByteToStr(tmp, txt);
Glcd_Write_Text("o", 60,0, 1);
Glcd_Write_Text(txt, 35,1, 1);
Glcd_Write_Text("TEMP =", 0,1, 1);
Glcd_Write_Text("C ", 70,1, 1);
if (tmp>20) {Glcd_Box(10, 50, 20, 70, 1); }
if (tmp<20) {Glcd_Box(10,50, 20, 70, 0); } if (tmp>40) {Glcd_Box(20, 45, 30, 70, 1); }
if (tmp<40) {Glcd_Box(20, 45, 30, 70, 0); } if (tmp>60) {Glcd_Box(30, 40, 40, 70, 1); }
if (tmp<60) {Glcd_Box(30, 40, 40, 70, 0); } if (tmp>80) {Glcd_Box(40, 35, 50, 70, 1); }
if (tmp<80) {Glcd_Box(40, 35, 50, 70, 0); } if (tmp>100) {Glcd_Box(50, 30, 60, 70, 1); }
if (tmp<100) {Glcd_Box(50, 30, 60, 70, 0); } if (tmp>115) {Glcd_Box(60, 25, 70, 70, 1); }
if (tmp<115) {Glcd_Box(60, 25, 70, 70, 0); } if (tmp>130) {Glcd_Box(70, 20, 80, 70, 1); }
if (tmp<130) {Glcd_Box(70, 20, 80, 70, 0); } if (tmp>140) {Glcd_Box(80, 15, 90, 70, 1); }
if (tmp<140) {Glcd_Box(80, 15, 90, 70, 0); } if (tmp>145) {Glcd_Box(90, 10, 100, 70, 1); }
if (tmp<145) {Glcd_Box(90, 10, 100, 70, 0); }
}
}
Display temperature on Graphic Liquid Crystal Display using PIC16F877A Microcontroller (Schematic Diagram)

Short Description
The code is very easy to understand . First we have defined Control and DATA pins of graphical LCD to PIC microcontroller . Then after we have displayed some text using function Glcd_Write_Text(“”, ,,); .Since we cannot write box using Glcd_Write_Text(); function we have to make our own box using the function Glcd_Box(x,y,-x,-y,on/off). These box are made to respective temperature and the box is used to represent the temperature . Thats all concept behind this project .
If you have any question about this project please comment below , if you like this project please share this .
-
What compiler is used to write the C code?
The compiler used is mikroC PRO for PIC V. 7.1.0. -
How does a graphical LCD differ from ordinary alphanumeric LCDs?
Graphical LCDs have 128x64 dots that can be lit individually to create pictures or custom characters, unlike ordinary LCDs which are limited to fixed character matrices. -
Can the LM35 sensor operate at temperatures below zero?
Yes, the LM35 works for a range of -55°C to 150°C. -
How is the temperature value converted for display?
The ADC read value is divided by 2.05 to convert it into a readable temperature format before being displayed. -
Which function is used to draw the temperature bars?
The Glcd_Box(x,y,-x,-y,on/off) function is used to create the boxes that represent the temperature levels. -
Does the bar graph update based on specific temperature thresholds?
Yes, the code uses if-else statements to turn bars on or off based on thresholds like 20, 40, 60, up to 145 degrees Celsius. -
What language level is used for the program?
The program is written in both C and Assembly level language.