Displaying 8051 counter on LCD

Thread Starter

Dritech

Joined Sep 21, 2011
901
Hi all,

I am using timer 1 as a counter in mode 2. After reading the value in TL1 , I need to do same calculations which will be stored in an integer.
After the calculation is done, I am trying to display the result on an LCD. Now my problem is that I cannot display the result using the integer variable directly since the LCD function accepts strings.
Is there a way to convert the value stored in the integer to a string please?

Any kind of help would be appreciated.
 

MrChips

Joined Oct 2, 2009
30,823
This is a classic early exercise in any introductory course on microcontroller programming.
Are you coding in ASM or C?

Be informed that the LCD itself does not accept strings. The input to the LCD is single 8-bit characters encoded in ASCII.
 

MrChips

Joined Oct 2, 2009
30,823
So you can either do it the easy way by using a library function such as sprintf( )

or you can do it the easier way by writing your own function to take a binary integer and stripping it down to its coefficients of power's of ten (which is dead easy to do).
 
Top