How to type/print superscript and subscripts

Hi All-

Thanks for your time, to read this and answer this topic.

I, wanted to include symbol of degree Celsius, ie., how can we print superscripts and subscripts on serial.print and lcd.print

Best,

Ramesha

This depends on the serial console you use and its capabilities to do smart formatting...usually a serial terminal is very basic and won’t do subscript or superscript...it’s not Word...

Same on a lcd, some have a degree symbol embedded as a character and you need to find which code to use. Look at the reference of your module.

Here is for example (copied from here) two possible character symbol tables (Each LCD might have a different set)

In the set on the left the degree symbol would be at 1101 1111 which is 0xDF so you can try:lcd.write(0xDF); and see what you get

You need to access the extended ASCII or UTF character sets for the devices you wish to print to. Subscripts and superscripts are a different issue but there are symbols in the extended ASCII character set for degree some common others. Check here.

Copy the ° before < and save it in a txt. file, unicode U+00B0

void setup()
{
  Serial.begin(9600);
}
void loop()
{
  Serial.print(36); Serial.println("°"); // ° <
}

Copy the ° before <- and save it in a txt. file, unicode U+00B0

void setup()
{
  Serial.begin(9600);
}
void loop()
{
  Serial.print(36);
  Serial.println("°"); // ° <-
}

Of course there's a better way, but I can't remember.