Printing specdial character on LCD[SOLVED]


If you want to print the degrees symbol (°) on lcd this seems to work:


since 223 is the aschii code for the above symbol in the LCDs character set. What if, like me, you want to use a char buffer to store each LCD line and then have it printed on lcd?


The above doesn't work and produces a different character!

Any ideas how to do it ?

The above doesnt work

You can't copy a character with strcpy (both arguments must be arrays, the second one a c-string as well).

Your example would probably do the below. Not tested.

buffer[0] = (char)233;

Then i need to know the exact position in the buffer array that the character is to be printed. The buffr array is constructed with a series of strcat comands...


char temperatureSymbol[2] = {(char)233, '\0'};

This you can use with strcpy, strcat etc.

Or you can use sprintf().

Note: in my previous reply, I assumed that buffer was initialised with zeroes (null erminators).

You can embed the character inside a string using a backslash followed by either a hex or octal number:

  lcd.print("\xDF"); //hex value for 223
  lcd.print("\337"); //octal value for 223

That worked! -Thank you!

I would imagine the same applies for a custom defined LCD character...

With custom characters, you can define up to 8, numbered 0 through 7. Avoid using 0 if possible, because 0 is the same as the terminating NULL and cannot be part of a string.

Yes i know.
Thanks for your help!