How to make LCD display a variable.

Status
Not open for further replies.

Mutad0r

Junior Member level 3
Joined
Feb 13, 2013
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,608
So, browsing older posts just got me confused..

I have a variable from 0-255, and I want to display it on an LCD, this seems like something common, but no good instructions. ( that I could find [and understand]). I do have an idea of how I would do it, but it would basically be processor harassment...

How exactly would one go about doing this?
 

To display a variable, consider this C example for a PIC microcontroller

You need to convert your 0-255 variable into a string of ASCII characters so that it can be displayed by the LCD.

For example if var1 = 214, so you need to convert it to a string '2','1', and '4' first.

This means you many need an array variable to hold the string.

var1 = 214;

var1String[4]; //hold 3 chars + 1 null character

then use maybe the sprintf function so that var1 is converted to string.

sprintf(var1String,"%d",var1);

then display the var1String to lcd.

lcd_puts(var1String);


Hope it helps.
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…