error: stray '\342' in program Serial.print(“Sensor Value: ");

Please help...What is wrong with this Sketch?

./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -build-path /tmp/164877037/build -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -libraries /tmp/164877037/pinned -libraries /tmp/164877037/custom -fqbn arduino:avr:uno -build-cache /tmp -logger humantags -verbose=false /tmp/164877037/sketch_feb5a

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:12:2: error: stray '\342' in program

Serial.print(“Sensor Value: ");

^

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:12:2: error: stray '\200' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:12:2: error: stray '\234' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:12:2: error: missing terminating " character

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:16:2: error: stray '\342' in program

Serial.print(“, Volts: “);

^

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:16:2: error: stray '\200' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:16:2: error: stray '\234' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:16:2: error: stray '\342' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:16:2: error: stray '\200' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:16:2: error: stray '\234' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:18:2: error: stray '\342' in program

Serial.print(“, degrees C: “);

^

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:18:2: error: stray '\200' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:18:2: error: stray '\234' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:18:2: error: stray '\342' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:18:2: error: stray '\200' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:18:2: error: stray '\234' in program

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino: In function 'void loop()':

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:12:18: error: 'Sensor' was not declared in this scope

Serial.print(“Sensor Value: ");

^

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:16:18: error: expected primary-expression before ',' token

Serial.print(“, Volts: “);

^

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:16:20: error: 'Volts' was not declared in this scope

Serial.print(“, Volts: “);

^

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:18:18: error: expected primary-expression before ',' token

Serial.print(“, degrees C: “);

^

/tmp/164877037/sketch_feb5a/sketch_feb5a.ino:18:20: error: 'degrees' was not declared in this scope

Serial.print(“, degrees C: “);

^

exit status 1

What is wrong with this Sketch?

At a guess you copied it from a Web page and some Unicode characters have been included.

Where did you get it from ?

The code is using some weird characters that look like standard double quotes but are not. Try this:

  • In the Arduino IDE: select the full text of your sketch.
  • Edit > Copy.
  • In a reply here on the forum: Click the code tags button on the toolbar (</>)
  • Edit > Paste
  • Click the "Preview" button (you don't need to actually post the reply.
  • In the preview of your reply, click the "Select" link in the code box.
  • In the Arduino IDE: Edit > Paste.

I believe the forum software will replace the bad characters for you and the problem will be solved.

:slight_smile: Thanks a bunch...I did copy and Paste...I understand it is nice to help understand how the code works if you physically type in the characters. But in my case I wish to get to designing and engineering physical projects while other people that enjoy code can take care of that for me. I have always been a team player, Never understood why they try to make us all so independent when half of country needs foods stamps. If we work together and people can focus on there part of making society better most likely everyone would be more happy and healthy and focused on living.

530pools:
help understand how the code works if you physically type in the characters

Naw, it's 2018. That idea is a holdover from people who learned to program in the days when you got computer programs printed in magazines so there was no choice. Copy/paste is an essential tool for any programmer. Spend the same amount of time studying the code and researching that you would have typing and you'll end up learning way more.

Unfortunately some web sites inject a bunch of hidden characters into the published code so that is a pitfall of the copy/paste. If you find code on GitHub or this forum it will be fine. It's probably more blogs where you'll have problems.

530pools:
If we work together and people can focus on there part of making society better

That's exactly what has made the Arduino project so great. It's amazing what can happen when people all over the world work together! Whether that's contributing code, reporting bugs, improving documentation, helping someone out on the forum, it all really adds up to a wonderful thing!

Spend the same amount of time studying the code and researching that you would have typing and you'll end up learning way more.

I think you miss out on understanding curly braces, brackets, parentheses, asterisks, colons, semicolons, etc. that way. The first few programs SHOULD be typed, not copied and pasted, until you understand the nuances of the syntax. Then, code reuse (AKA copy/paste) can be used.

You have wrong kind of quotes there, \342\200\234 is left double quote. Change them to normal straight double quotes.

I understand missing the curly braces and brakets and colons and all this is very important. And next time I will just type in the code. Thank you all so much for your help...a 45minute project turned into hours of stress when I could have typed the code 100 times over. Have a wonderful day friends and thank you again. :slight_smile: