# Lcd library functions

**URL:** <https://forum.arduino.cc/t/lcd-library-functions/1090442>\
**Category:** Displays\
**Created:** [February 15, 2023, 8:07am UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442 "2023-02-15T08:07:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![petercl14](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/petercl14/32/1013044_2.png) [@petercl14](https://forum.arduino.cc/u/petercl14)\
**Post date:** [February 15, 2023, 8:07am UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442/1 "2023-02-15T08:07:20Z")

</div>

Hi all, I notice in the lcd library there is no function to print a variable. I have tried this;  
lcd.println(n);  
lcd.print("c");  
I gave n the value 18 before set up. On the lcd display I get the 18 but after that there is what looks like 4 'U's laid on their side. After that is the 'c' and then the cursor. I need to be able to print out a variable on the lcd with a 'c' for centigrade on the screen. How can I do this without the 'U's? Thanks.

---

<div class="post-metadata">

**Author:** ![guix](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/guix/32/215371_2.png) [@guix](https://forum.arduino.cc/u/guix)\
**Post date:** [February 15, 2023, 8:10am UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442/2 "2023-02-15T08:10:16Z")

</div>

Hello

Don't use `println`

What type is variable `n` ? If it's a char array, make sure it is null-terminated

---

<div class="post-metadata">

**Author:** ![noiasca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noiasca/32/1126910_2.png) [@noiasca](https://forum.arduino.cc/u/noiasca)\
**Post date:** [February 15, 2023, 8:17am UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442/3 "2023-02-15T08:17:47Z")

</div>

use print.

> [@petercl14](#):
>
> lcd.print(n);

if it doesn't work for you - show a complete compileable sketch in code tags.

---

<div class="post-metadata">

**Author:** ![petercl14](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/petercl14/32/1013044_2.png) [@petercl14](https://forum.arduino.cc/u/petercl14)\
**Post date:** [February 16, 2023, 3:03am UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442/4 "2023-02-16T03:03:33Z")

</div>

Thanks guix. That has fixed it. In ordinary programming, not in the lcd library, to print a variable number you have to use println(n). So I have used print(n) for a variable where n is an int and a number. Because 'c' is a character I use print("c"). If I wanted a decimal number I wouldn't use 'int'. So now I can easily vary 'n' in the display. Now showing on display as '18c\_' where the stroke is the cursor. '18' was set earlier as intn=18. Can later in the program change the value of 'n' to any other int number.

---

<div class="post-metadata">

**Author:** ![petercl14](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/petercl14/32/1013044_2.png) [@petercl14](https://forum.arduino.cc/u/petercl14)\
**Post date:** [February 16, 2023, 3:06am UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442/5 "2023-02-16T03:06:12Z")

</div>

yes should be lcd.print(n).

---

<div class="post-metadata">

**Author:** ![noiasca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noiasca/32/1126910_2.png) [@noiasca](https://forum.arduino.cc/u/noiasca)\
**Post date:** [February 16, 2023, 4:43am UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442/6 "2023-02-16T04:43:30Z")

</div>

it's seems you still have a misunderstanding about print and println.

Both functions take the same parameters. Meaning you can use them to print constant text or variables and modifiers the same way. The only difference is that println adds a CR LF at the end. If you check the implementation of print and println (you find them as par of the Print.h and Print.cpp) you will see that even if you call println it will first call print and afterwards adds the CR LF.

---

<div class="post-metadata">

**Author:** ![anon56112670](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@anon56112670](https://forum.arduino.cc/u/anon56112670)\
**Post date:** [February 16, 2023, 5:56pm UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442/7 "2023-02-16T17:56:45Z")

</div>

> [@petercl14](#):
>
> to print a variable number you have to use println(n).

No you don't _have_ to use println.  
You only use println if you want a newline after the value you printed

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 15, 2023, 5:56pm UTC](https://forum.arduino.cc/t/lcd-library-functions/1090442/8 "2023-08-15T17:56:55Z")

</div>

Closed on August 15, 2023, 5:56pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
