Such a simple noob question - print a ASCI character

Hi all,
I just purchased my first network module to run as a web server. All good and works well, but I want to change things like font colours and size and even add images to my code. The issue is that most of the code wants speech marks for some code and this destroys the compiler like:

<font size="6">This is some text!</font>

So I know what I need to do is display some text, then tell it to print a string which has the value of a speech mark, then more code, then another speech mark and so on.
Sounds simple, but I have only been playing with Arduino for around 4 weeks now so still learning.

Can anybody help please.

Thanks
Alan

If you want to put a quote mark inside a string, you need to add a "\":

Serial.print("this is a quote mark: \"");

Only just got this (no email alert when you replied). Thank you so much, this is such a simple way of doing it and it makes me very happy.Thank you luisilva for your quick reply. I will have a play with this tomorow.

WooleySheep:
Hi all,
I just purchased my first network module to run as a web server. All good and works well, but I want to change things like font colours and size and even add images to my code. The issue is that most of the code wants speech marks for some code and this destroys the compiler like:

<font size="6">This is some text!</font>

::::

WooleySheep,
Can you please clarify where you want the output. The web? or the Serial?
Can you also clarify what you mean with the phrase speech marks?
Also, It is complete not clear – to me – what you mean with destroys the compiler?

TIA
Jesse

He wanted to know why this string for example:

"<font size="6">This is some text!</font>"

would not compile ( destroy the compiler ), and the answer is, because the double quotes ( ", speech marks ) must be escaped ( " )

"<font size=\"6\">This is some text!</font>"

Else the compiler will understand the string as
"<font size="
followed by garbage…

:slight_smile:

Edit: It’s worth mentioning that it is also possible to do that:
R"(<font size="6">This is some text!</font>)"; (R stand for raw)

guix: He wanted to know why this string for example:

::::

Thanks guix, I figured as much. But I really wanted WooleySheep to answer. As such, I can ask what is really wanted. Reading between the lines, it's clear this person may not be familiar with HTML or HTTP. As such, how this may be accomplished depends on this person's knowledge.

Thanks Again Jesse

Ok guys, the ol'e man has himself backed into a corner again. This time with a similar situation of sending the " character as part of a string. I've tried the \" and the compiler reports - sketch_feb16b:28: error: stray '\' in program. What I am trying to do is connect an 8266 wifi module to my router.

The AT command is: AT+CWJAP="SSID","KEY" then crlf.

I'm building off a sketch from Miguel at allaboutee.com who takes the approach of creating a sendData function with 3 parameters. 1 the command, 2 timeout, 3 boolean (for testing) to send AT commands to the 8266. He doesn't show this particular command being created, which I think is the most complex to be dealt with due to the quotes, which must be sent, as well as a comma have to be concatenated into a string that will be sent so as not to be seen as an extra parameter being added to the sendData function. I didn't think it would be as difficult as I've made it. I know I'm missing something but don't know what. Heres where I've gotten to:

sendData("AT+RST\r\n",2000,DEBUG); // reset module sendData("AT+CWMODE=1\r\n",1000,DEBUG); // configure as station sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections String idstring = ("ssid"); String keystring = ("key"); String connectstring = "AT+CWJAP="; connectstring += idstring; connectstring += ","; connectstring += keystring; connectstring += "\r\n";

So the whole connect string should be sent as AT+CWJAP="ssid","key(password)" \r\n

sendData(connectstring,1000,DEBUG);

In this case if DEBUG is true, the response from the 8266 is sent to the serial monitor. What I see comming back is: AT+CWJAP=myssid,mykey

Ok guys, the ol'e man has himself backed into a corner again. This time with a similar situation of sending the " character as part of a string. I've tried the \" and the compiler reports - sketch_feb16b:28: error: stray '\' in program. What I am trying to do is connect an 8266 wifi module to my router.

The AT command is: AT+CWJAP="SSID","KEY" then crlf.

I'm building off a sketch from Miguel at allaboutee.com who takes the approach of creating a sendData function with 3 parameters. 1 the command, 2 timeout, 3 boolean (for testing) to send AT commands to the 8266. He doesn't show this particular command being created, which I think is the most complex to be dealt with due to the quotes, which must be sent, as well as a comma have to be concatenated into a string that will be sent so as not to be seen as an extra parameter being added to the sendData function. I didn't think it would be as difficult as I've made it. I know I'm missing something but don't know what. Heres where I've gotten to:

sendData("AT+RST\r\n",2000,DEBUG); // reset module sendData("AT+CWMODE=1\r\n",1000,DEBUG); // configure as station sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections String idstring = ("ssid"); String keystring = ("key"); String connectstring = "AT+CWJAP="; connectstring += idstring; connectstring += ","; connectstring += keystring; connectstring += "\r\n";

sendData(connectstring,1000,DEBUG);

So the whole connect string should be sent as AT+CWJAP="ssid","key(password)" \r\n

In this case if DEBUG is true, the response from the 8266 is sent back thru the UNO to the serial monitor. What I see coming back is: AT+CWJAP=myssid,mykey

Serial.print("\"");

works for me.

the whole connect string should be sent as AT+CWJAP="ssid","key(password)" \r\n

You can send that with a series of Serial.print()s if you need to.

Yeah, but it's not going to serial, it's going to a software serial, but the premise is the same and it does work. IE: String idstring = ("\"ssid\""); String keystring = ("\"key\""); String connectstring = "AT+CWJAP="; connectstring += idstring; connectstring += ","; connectstring += keystring; connectstring += "\r\n"; sendData(connectstring,1000,DEBUG);

Thanks UKHeliBob :)

Yeah, but it's not going to serial, it's going to a software serial, but the premise is the same and it does work. IE:

No surprise there.

Now do it again properly using strings instead of Strings and use sprintf() to format the output.