Error: Stray '\' When Referencing Serial.print

If I copy this code into Arduino-0013:

/*************************** * Blinking LED (2) **************************/

int ledPin = 13; // LED connected to digital pin 13

int i = 0; // loop counter variable

void setup() // run once, when the sketch starts

{

pinMode(ledPin, OUTPUT); // sets the digital pin as output

Serial.begin(9600);

Serial.println("Starting...");

}

void loop() // run over and over again

{

Serial.print(“Loop #”); // print this string with no CR or LF

Serial.println(++i,DEC) // add 1 to i, print i in decimal format

// add CR and LF

digitalWrite(ledPin, HIGH); // sets the LED on

delay(400); // waits for a second

digitalWrite(ledPin, LOW); // sets the LED off

delay(1300); // waits for a second

}

and then click the "verify" button, I will get an :"error: stray '\' in program in function 'void loop()' and the line

Serial.print("Loop #");

is highlighted.

I can't seem to find a stray '\' character in the function. This error happens in both the Windows and Linux (32 bit) versions of Arduino-0013.

Can anyone help?

Thanks

Bob

Youve missed a “;” in this line.
Serial.println(++i,DEC)

Common easy to do mistake that usualy needs a second set of eyes to find till you get your eye in.
When posting code on the forum wrap it in the code tags.
Its the # button above the editor.
Makes it easier to read.

Gordon

Thanks for pointing out the missing semicolon. There was one other problem with it. I had actually copied this code from a website on the internet and pasted it into the Arduino-0013 IDE to try it out. If you look carefully at the quotes on the very first Serial.print line, you will see that they are curly double quotes. You can see this better if you look at the code I put in my original post above.

Serial.print(“Loop #”);       // print this string with no CR or LF

They are not straight double quotes which is the ASCII character the Arduino IDE considers to be a double quote.

Serial.print("Loop #");       // print this string with no CR or LF

It was the first form, the curly double quote, character that the compiler action was flagging, and it took a long, long time for me to figure it out. I just had to change the original curly double quotes to straight double quotes.

Here is the solution code:

/*
Blinking LED
*/
int ledPin = 13;                 // LED connected to digital pin 13
int i = 0;                       // loop counter variable
void setup()                     // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);       // sets the digital pin as output
  Serial.begin(9600);
  Serial.println("Starting...");
}
void loop()                     // run over and over again
{
  Serial.print("LOOP # ");         // print this string
  Serial.println(++i, DEC);       // add 1 to i, print i in decimal format
                                // add CR and LF
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(400);                   // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1300);                  // waits for a second
}

I was sweating a bit until comparing an example of Serial.print from the arduino.cc code reference made me start to see what the problem was.

Thanks

Bob