kr0490 wrote:I have a 16x2 LCD I got from sunfounder hooked up through i2c on my Pi3. I can make messages display but can't figure out the correct way to get values (like current temp) to display on the lcd. The working commands I use for text are
LCD1602.write (0,0, 'Message')
and that works but how do I format it to display a changing variable, such as temp for temp=GPIO.input (27)
No disagreement with what @Major Tom has said, but to add to it a little..
The simplest demonstration of displaying an integer is something like:
If your variable temp
actually contains an integer representing the temperature then you could use:
(Examples untested as I don't have the display or software you are using.)
a changing variable, such as temp for temp=GPIO.input (27)
Temperature is an analogue (continuously varying) quantity. The gpio pins on the RPi header can only detect or be set to DIGITAL (binary) values represented by names such as 0/1, True/False, On/Off.
You cannot simply read the temperature from a gpio pin without the addition of some external analogue-to-digital conversion.