Printing degree celcius symbol in arduino

Hey guys,

I was wondering on how can I print the degree celcius symbol to my LCD.

From what I read, they mention about lcd.print((char)223); Then how would I print the 'C' ? Another line ?

Is it like this :

lcd.print(celcius, DEC);
  lcd.print((char)223);
  lcd.print("C");

Anyway, what does lcd.print((char)223) means ?

Thank you

what does lcd.print((char)223) mean

It means print an ASCII character with the value of 223.
Each symbol you print is a number, so to print A you have to use the number 65 so:-

lcd.print((char)65)

would print the letter A on the LCD, as would:-

lcd.print('A')

Just to confuse you :wink: :
You could also use lcd.write (223).

As it's only a print, you'll still be at the same line.
So you can send the "C" after that and it will appear next to the degree symbol.
lcd.println (value) will go to the next line after it has printed the value.
So yes, it would be like you posted (but without the indents).

Which indents ?

Thank you :slight_smile:

So, you mean I can use lcd.write(65) or lcd.print("A") for displaying a character 'A' on LCD ?

Thanks

So, you mean I can use lcd.write(65) or lcd.print("A") for displaying a character 'A' on LCD ?

Yes, the advantage of the first is you don't have to be able to type it from the keyboard as some characters do not appear on the keyboard.

Thank you so much. New knowledge for me :)))

Another way would be:

  lcd.print("\xDF""C");

The '\x' says that a hexadecimal code follows. The 'DF' is the hexadecimal equivalent of 223. You have to separate the \x in speech marks in order to stop the 'C' being detected as a part of the hex code.

So the above is equivalent to:

  lcd.print((char)223);
  lcd.print("C");

Just in a single call rather than two.