Project 2 - What is the best way to send integers to LCD?

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Project 2 - What is the best way to send integers to LCD?

Postby obsoletepower » Tue Mar 05, 2013 11:53 am

Hey everybody,

I got Project 2 to work and it works great for sending strings to the LCD but obviously not for regular integers so I am wondering what the best way to approach this is. Would I convert the int to ASCII and send that using the lcd_putchar function or is there a better way? I am using HI-TECH 9.80 with a PIC18F4620 MCU. Any suggestions would be greatly appreciated.
obsoletepower
Fledgling
 
Posts: 1
Joined: Tue Mar 05, 2013 11:49 am

Re: Project 2 - What is the best way to send integers to LCD

Postby robosang » Wed Mar 06, 2013 8:04 am

I think you can check some of example code from Cytron tutorial, or DIY project.

Check those that have LCD displaying number, I cannot remember which, maybe check out the tutorial for SK40C
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: Project 2 - What is the best way to send integers to LCD

Postby shahrul » Wed Mar 06, 2013 8:56 am

I use this code
CODE: SELECT_ALL_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=i+1;}
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');}
}
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 3 guests