stray \ 342 in program ?

Hi.All
When i run this sketch i get the above error, can anyone help me overcome it.

#include <LiquidCrystal.h>

LiquidCrystal lcd(8,9,4,5,6,7);
float rainfall = 0;
int rain_sensor = 2;                //set rainsensor to pin 2

void setup() {
digitalWrite(rain_sensor, LOW);     //set pin 2 low
pinMode(rain_sensor, INPUT);        //set pin 2 as an input
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Total Rainfall”);
lcd.setCursor(5,1);
lcd.print(rainfall);
lcd.print(” mm”);
}

float get_rainfall()
{
 a:  if (digitalRead(rain_sensor) == HIGH)
          {
           return 0.8;
          }     
 delay(200);         
 goto a;           
}

void loop() {
get_rainfall();
rainfall = rainfall + get_rainfall();
lcd.setCursor(5,1);
lcd.print(rainfall);
lcd.print(” mm”);
delay (1000);
}

[codeArduino: 1.8.5 (Windows 7), Board: “Arduino/Genuino Uno”

sketch_may14f:13: error: stray ‘\342’ in program

lcd.print(“Total Rainfall�);

^

sketch_may14f:13: error: stray ‘\200’ in program

sketch_may14f:13: error: stray ‘\234’ in program

sketch_may14f:13: error: stray ‘\342’ in program

sketch_may14f:13: error: stray ‘\200’ in program

sketch_may14f:13: error: stray ‘\235’ in program

sketch_may14f:16: error: stray ‘\342’ in program

lcd.print(� mm�);

^

sketch_may14f:16: error: stray ‘\200’ in program

sketch_may14f:16: error: stray ‘\235’ in program

sketch_may14f:16: error: stray ‘\342’ in program

sketch_may14f:16: error: stray ‘\200’ in program

sketch_may14f:16: error: stray ‘\235’ in program

sketch_may14f:34: error: stray ‘\342’ in program

lcd.print(� mm�);

^

sketch_may14f:34: error: stray ‘\200’ in program

sketch_may14f:34: error: stray ‘\235’ in program

sketch_may14f:34: error: stray ‘\342’ in program

sketch_may14f:34: error: stray ‘\200’ in program

sketch_may14f:34: error: stray ‘\235’ in program

C:\Users\dell\Documents\Arduino\sketch_may14f\sketch_may14f.ino: In function ‘void setup()’:

sketch_may14f:13: error: ‘Total’ was not declared in this scope

lcd.print(“Total Rainfall�);

^

sketch_may14f:16: error: ‘mm’ was not declared in this scope

lcd.print(� mm�);

^

C:\Users\dell\Documents\Arduino\sketch_may14f\sketch_may14f.ino: In function ‘void loop()’:

sketch_may14f:34: error: ‘mm’ was not declared in this scope

lcd.print(� mm�);

^

exit status 1
stray ‘\342’ in program

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.
][/code]

The quotation marks in your sketch are "smart quotes", the stylized quotes that Microsoft Office products replace normal quote marks with to make it "look better"; in other words, the sketch was copy'pasted into and out of microsoft word/outlook/etc, or from a website that did the same thing.

The smartquotes are unicode characters that are not valid an arduino sketch - only real quote marks are valid.

Solution is simple - delete each quotation mark and retype it.

DrAzzy.

Many thanks, you are correct, i did cut and paste from the instructables web site. i did as you recommended and the sketch "compiled" first time, unfortunately when uploading i immediately got the following  can you help again please ?

[codeArduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Uno"

Sketch uses 4158 bytes (12%) of program storage space. Maximum is 32256 bytes.
Global variables use 81 bytes (3%) of dynamic memory, leaving 1967 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b115200 -D -Uflash:w:C:\Users\dell\AppData\Local\Temp\arduino_build_107122/sketch_may14f.ino.hex:i 

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x81

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
]

Most people have trouble finding the code tags, you past everything in it...

But now you jut have a competely different problem. The computer simply doesn't get response from the Arduino. Welcome to Installation & Troubleshooting. Please have a look :)

sorry septillion, i thought i had used the tags, perhaps i need more practice ?

I do not wish to upset anyone, but has i have stated before, this Arduino is a hobby for me, yes i have a need to learn, but this is the only forum i have found that can give expert help. You mention wanting something for nothing or words to that effect, yes i could pay someone but who? i cannot find help locally, there are no college lessons in my local area so i have to self learn, this i am willing to do, but i am 70 years old, with 50 years working in Mechanical Engineering, sometimes things take time to sink in the old grey matter, no offence but give us beginners a bit of slack, or do not invite us to join your forums.

Ray Smith

gresleyman: sorry septillion, i thought i had used the tags, perhaps i need more practice ?

You did, you only did everything inside them, including your response ;)

And no hard feelings :) But now you need to do the checks that are in that section. Aka, fist check if you selected the right board (including possible sub-settings depending on the board you have). Do you really use a Uno? Second, if you selected the right COM port. Did you buy it of eBay/Ali/Amazon? Than it's probably one with a CH340, did you install that driver? Check device manager to see if there are any devices with an !. If that's all okay and you still have trouble, do a loop back test.

Hi.

I have have checked in the tools menu, and it states i have connected a Arduino UNO, it is on Com port 8 and the programmer is set to ArduinoISP.

I have a spare UNO, i connected it up to my pc, and immediately on the Screen came up a window saying new drivers found and successfully downloaded, but when i came to upload the sketch, i have the same alarm fault again ??

I have downloaded that Driver you gave me into the driver folder of my DELL FOLDER. things are still the same still the same.

One thing i have noticed is when you select TOOLS - port there seems to be only one Port setting on offer, if i pull out the serial cable, then reconnect, i sometimes get either com, 1,4,6 or 8 available, if i click on any of these, that com port is displayed in the Tools menu , but i still get the same error message.

Ray

gresleyman: I have have checked in the tools menu, and it states i have connected a Arduino UNO, it is on Com port 8 and the programmer is set to ArduinoISP.

No it does not ;) It states YOU selected that, no matter if that's correct or not :D And when using the USB on a Uno/Nano and the normal upload button, the programmer selection doesn't matter.

Question, if there is no Arduino connected, what does tools->Com-port show? And when you connect an Arduino? (Hint, there should be one COM-port extra when the Arduino is connected.

Hi Septillion, thanks for your help so far.

I plug in the Arduino to a USB port at the front of my Desktop pc, then i click on the Arduino icon on my desktop, then i open up the sketch, then i go to tools, there is 2 comports showing, if i open the IED without the UNO connected there is only one showing.

Please see my uploaded photos
Regards

Ray

1dbe1f4388a98fa5f94d68b4f393a6b4c72136ba.jpg

482d078827ea0199bdd3e97c2bc91a2bdf81a1fd.jpg

Both images show the same so it’s hard to tell, but if a COM pups up after connectiong the Arduino changes are big it’s indeed the Arduino and that it’s recognized.

Is it indeed an Uno?
Are there things connected to the Arduino?
Did it use to work?

Hi Septillion.

Before i connect the Arduino to my PC there is only COM 1 showing in the Tools menu, when i plug in the Arduino my PC sometimes picks it up and sometimes it does not, i have 4 Uno's and all have been given different com ports by the PC at times.

Yesterday i borrowed a friends laptop, i downloaded the latest IDE from the Arduino web site, i then one by one tried out all 4 UNO's one worked immediately and the PC designated it has COM port 8, i do have 8 com ports, what's going on i wonder?

Ray

Windows assigning different COM names to different boards, USB ports and/or after it has been disconnected. You just gave to look for the last one that appeared. On XP this was the worst but on Win 10 most of the time the same Arduino (or with the same USB chip) plugged into the same USB port gets the same number.

If that still does not work, did you open up device manager as I told? ;)

I have uploaded this jpeg of my PC screen in Device Manager. The strange thing is that i took the photo image downloaded to a SD memory card, i have a USB 2 card reader, i placed the SD card into the reader , then i inserted the card reader into a com port at the front of my PC windows detected it immediatley and designated it "E" drive.

Ray

You do know you can take print screens of your PC? Easier and a heck lot better readable :) Just type sniping tool into the start menu :)

Many thanks for that great info, i said i was learning all the time.

Ray

Hi Septillion.

If you are reading this many thanks for your help. I know have things up and running again, i think the main problem was a driver issue on my PC, i downloaded a driver fix software went through the motions and everything is working again, strangely though, only on 1 of my 4 boards? another challenge another day,

Regards

Ray