Displaying number i n 16x2 Display using pic16f877a

Thread Starter

karthi keyan 9

Joined Apr 17, 2018
30
Hi, i want display numerical in 16x2 display.

i included conversion in the lcd code but it is displaying some wrong values,

output in display:
cap sensorw&π&π ---------Line 1
orororw&π&π ----------------Line 2

Actually i should get 100 in the dispaly

Code ;
C:
//#include<htc.h>
#include<pic.h>

#define RS RB5
#define EN RB4
#define D4 RB0
#define D5 RB1
#define D6 RB2
#define D7 RB3


#define _XTAL_FREQ 11059200
#include "lcd.h"

__CONFIG (0xFF02);

Lcd4_Clear();
char a=100;
void main()
{
int i,b,c1,c2,c3;
char s[]={'C','a','p',' ','S','e','n','s','o','r',0};
TRISB = 0x00;
Lcd4_Init();
Lcd4_Clear();

Lcd4_Set_Cursor(1,1);

Lcd4_Write_String(s);

for(i=0;i<255;i++);

while(a)
{
b=a/100;
c1=a%100;
c2=c1/10;
c3=c1%10;
Lcd4_Cmd(0x80);
Lcd4_Set_Cursor(2,1);
Lcd4_Write_String(b+0x30);
Lcd4_Write_String(c2+0x30);
Lcd4_Write_String(c3+0x30);
//Lcd4_Port(b+0x30);
//Lcd4_Port(c2+0x30);
//Lcd4_Port(c3+0x30);
for(i=0;i<500;i++);
}
}
anybody getting what i am doing here? Looking for replies
 
Last edited by a moderator:

Ian Rogers

Joined Dec 12, 2012
689
To print a character just use "Lcd4_Write" as the string will barf!!

It might be
Lcd4_Data(b+0x30);

Lcd4_Write(b+0x30);
Lcd4_Write(c2+0x30);
Lcd4_Write(c3+0x30);
 
Last edited:
Top