Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com 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.

Display "int" values on LCD

Status
Not open for further replies.

Neyolight

Full Member level 5
Joined
Aug 29, 2011
Messages
306
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
World
Activity points
3,624
Hey all

Im using C18 complier on MPLAB with PIC18F.
How do i display an "unsigned int" variable on to the LCD that changes every 1 sec.


Thanks
 

Your problem is to display integer or display number every 1 sec?
 

well , there must be a inbuilt function, something like inttostr (you might need to convert the int value to a string before displaying to a character LCD). I use HI-TECH C so i don't know about c18 properly..!

INFO please.... what LCD is it..?
try in the compiler help for inbuilt library routines..
 

Both. Im stuck with both problems
This is my function to display number. You can display in any order like decimal, hexadecimal or binary. You can convert this into PIC18.
Code:
void lcd_number(unsigned int no, char base, char digit)
{char i,j,di[10];
for(i=0;i<=9;i++) di[i]=0;
i=0;
do{
	di[i]=no%base;
	no=no/base;
	i++;}
while(no!=0);
for(j=digit;j>0;j--){
	if(di[j-1]<=9) lcd_write(di[j-1]+'0');
	else lcd_write(di[j-1]-10+'A');}
}
You can see example here.

For display every 1 sec, you can use Timer Interrupt. Do a counter in the interrupt. In the main program, if the counter reach to a value, the display number and clear back the counter. You can see example calculate 1s using Timer here.
 
Thanks all :)
engshahrul - I will give your code a try today and see how it works for me :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top