Pages: [1]   Go Down
Author Topic: Printing special characters  (Read 1620 times)
0 Members and 1 Guest are viewing this topic.
Adelaide, South Australia
Offline Offline
Full Member
***
Karma: 0
Posts: 139
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where can I find a list of all the special characters for char arrays and printing, like \n, \o and similar

Also how would I print the little superscripted 'o' symbol for degrees C or F, e.g. in 27<degrees symbol>C

TIA
Logged

West Des Moines, Iowa USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 428
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

From The C Programming Language:

\a   alert (bell) character
\b   backspace
\f   formfeed
\n   newline (linefeed)
\r   carriage return
\t   horizontal tab
\v   vertical tab
\\   backslash
\?   question mark
\'   single quote
\ddd octal constant
\xhh hexadecimal constant

The degree symbol (as in 27°C) is unknown to C and (I think) C++ and printing it will probably involve device dependencies.
Logged

There's always a better way!

alabama
Offline Offline
Full Member
***
Karma: 1
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ninja2,
Try this page, you can even create your own custom character.
http://www.quinapalus.com/hd44780udg.html
TomJ
Logged

Einstein once said you don't really understand anything until you can explain it to your Grandmother

alabama
Offline Offline
Full Member
***
Karma: 1
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ninja2,
Just read a way to print the degree symbol on another post.
It's at the  bottom of the alternative code for averaging.
http://arduino.cc/forum/index.php/topic,99557.0.html
TomJ
Logged

Einstein once said you don't really understand anything until you can explain it to your Grandmother

Adelaide, South Australia
Offline Offline
Full Member
***
Karma: 0
Posts: 139
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

excellent help, thanks all

I must use/learn that list of backslash codes ...

found the magic syntax too ...

Code:
lcd.print((char)223);    // degree

yeeha  smiley  smiley    


... great forum, friendly players, top advice, fascinating topic(s) smiley
« Last Edit: April 03, 2012, 02:04:23 pm by ninja2 » Logged

Adelaide, South Australia
Offline Offline
Full Member
***
Karma: 0
Posts: 139
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The degree symbol (as in 27°C) ...

Morris - how did you insert / type the degree symbol into your text above ?
Logged

West Des Moines, Iowa USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 428
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

On this keyboard the degree symbol is shift+option+8 (An * that's turned into a ° by the option key).

You can do the same thing on a Windows keyboard by holding down the Alt key and typing in a code on the numeric keypad - but I've already forgotten the code.  :-(
Logged

There's always a better way!

Adelaide, South Australia
Offline Offline
Full Member
***
Karma: 0
Posts: 139
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

º how about alt+0186 º  smiley
ºXºXºXº
google is so amazing these days, I just googled "How to type degree symbol on PC" and bingo
Logged

Central MN, USA
Online Online
Tesla Member
***
Karma: 65
Posts: 6922
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

º how about alt+0186 º  smiley
ºXºXºXº
google is so amazing these days, I just googled "How to type degree symbol on PC" and bingo

Next day Google will push books ad to you that features a whole chapter on "How to type degree symbol on PC"  smiley-wink
Logged


West Des Moines, Iowa USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 428
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If the Extended ASCII code is 233, then you should be able to embed it in a string as

   char *temperature = "Today's high temperature is 27\xE9""C"

But my wimpy bash terminal window displays it as a question mark.  :-/
Logged

There's always a better way!

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

from Morris:
\n   newline (linefeed)
\r   carriage return

I assume \r sends only a 13, but does \n send only a 10, or both 10 + 13?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46227
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I assume \r sends only a 13, but does \n send only a 10, or both 10 + 13?
Depends on what is doing the sending, on what operating system.
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Depends on what is doing the sending, on what operating system.

How about this one: Serial.print("\n");
Logged

Adelaide, South Australia
Offline Offline
Full Member
***
Karma: 0
Posts: 139
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Next day Google will push books ad to you that features a whole chapter on "How to type degree symbol on PC"  smiley-wink

LOL , and I'm a the perfect target for such smiley
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46227
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How about this one: Serial.print("\n");
Sends exactly one byte - the new line value, 10. to the serial port.
Logged

Pages: [1]   Go Up
Jump to: