Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] [Help Needed] LCD Display in Mikroelektronica EasyPic5 Board using PIC18F4550

Not open for further replies.


Junior Member level 2
May 16, 2011
Reaction score
Trophy points
Activity points

There seems to be a problem in our code because whenever we use PIC18, the LCD doesn't display anything but when we used PIC16, there is a display BUT to our dismay, it is displayed in ASCII.

Can someone please help me debug my code so that I can display the results (hopefully not in ASCII anymore) in our LCD using PIC18?

By the way, we're using MikroC Pro to code this.

Thank you and would really appreciate any help.

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
unsigned int temp_h1; temp_h2, temp_h3, , temp_c2, temp_c3;
float battery_voltage;

unsigned int tempdiff1; tempdiff2, tempdiff3;
unsigned int *min_tempdiff = 0x50; //0101 0000

void main()
ADCON1 = 0x00; //Configure ADC pins as analog
TRISA = 0xFF; //PORTA is input
TRISE = 0x0F; //PORTE bits 4-0 are input

temp_h1 = ADC_Read(0);
temp_h2 = ADC_Read(1);
temp_h3 = ADC_Read(2);

temp_c1 = ADC_Read(3);
temp_c2 = ADC_Read(4);
temp_c3 = ADC_Read(5);
battery_voltage = ADC_Read(7);

TRISB = 0x00;
TRISD = 0x00;
TRISE = 0x00;

tempdiff1 = temp_h1 - temp_c1;
tempdiff2 = temp_h2 - temp_c2;
tempdiff3 = temp_h3 - temp_c3;
PORTB = temp_h1;
temp_h1 = temp_h1 + 48;
Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

PORTC = temp_c1;
PORTD = tempdiff1;


To display the value, you need to convert the integer to a string.
I am not familiar with MikroC, but it should support the c standard library function sprintf.

Look up their support for sprintf in the documentation.

#include <stdio.h>

void display_value(void)
  unsigned int value = 22;
  char buffer[16];  /* size of line on display */
  sprintf(buffer, "Value is %d", value);  /* Same formatting options as printf */

  Lcd_Out(1,1, buffer);                   /* Your call to display function */
Last edited:

Tried the equivalent of sprintf in MikroC Pro and it worked :) Thank you very much!

MikroC also has two more compact and less resource intensive variants of sprintf(), sprinti() and sprintl(). If your conversions involve only integers or longs, the use of these two functions respectfully saves you cycles, RAM and ROM.

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to