Serial.begin woes

Copied from Arduino course second edition.

//Type your code into your Arduino "exactly" as you see here.
//Don't worry about What the program does - this is about practicing the syntax.

//This is a single row comment. What color is the text?
// Will the compiler these comments?

/*
This is a multi-line comment.
Will the compiler see these words?
Are these multi-line comments colored different than the single line comments.
/*
string dog; //Which of these words is a keyword? How do you know?
*/
//Setup only runs once.
//void setup(){ //notice that this setup() has a different color.

//Comments are meant to explain your code to you and othr people.

//Setup serial Communication.
Serial.begin (9600);//This is the color of the library function.

}//this curly bracket "closes" the setup function.// Put your main code here to run repeatedly;
void loop() { // This curly bracket opens the loop() function.

//Assign a bark to the dog.
dog = "bark";

//Send the bark to the computer.
Serial.printin(dog);

//Upload this code to the Arduino (CONTROL + U) and open the Serial Monitor Window (SHIFT + CONTROL + M)

} //This curly bracket closes the loop() function.

Arduino: 1.6.6 (Windows 10), Board: "Arduino/Genuino Uno"

sketch_oct28a:20: error: 'Serial' does not name a type

Serial.begin (9600);//This is the color of the library function.

sketch_oct28a:22: error: expected declaration before '}' token

}//this curly bracket "closes" the setup function.// Put your main code here to run repeatedly;

exit status 1
'Serial' does not name a type

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

In this forum... you should always include any code inside the </> quotes.

The code has a lot of errors... was the point of the exercise to get you to fix the errors? or was this code supposed to work first time?

Hi, @jagfan13
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

Please post your code.
What model Arduino controller are you using?
What is you code supposed to do?

Which course, can you please post a link?

Go back and check each line with where you copied it from, there are some missing lines and too many comment /* */.

Tom... :smiley: :+1: :coffee: :australia:

Either you did a poor job of typing the example or the example had a bunch of errors.

// This is a single row comment. What color is the text?
// Will the compiler these comments?

/*
  This is a multi-line comment.
  Will the compiler see these words?
  Are these multi-line comments colored different than the single line comments.
*/
String dog; //Which of these words is a keyword? How do you know?

// Setup only runs once.
void setup()   //notice that this setup() has a different color.
{
  //Comments are meant to explain your code to you and othr people.

  //Setup serial Communication.
  Serial.begin (9600); //This is the color of the library function.

}  //this curly bracket "closes" the setup function.// Put your main code here to run repeatedly;

void loop()   // This curly bracket opens the loop() function.
{
  //Assign a bark to the dog.
  dog = "bark";

  //Send the bark to the computer.
  Serial.println(dog);

  //Upload this code to the Arduino (CONTROL + U) and open the Serial Monitor Window (SHIFT + CONTROL + M)

} //This curly bracket closes the loop() function.

The code you typed in has 2 '/' at the start of this line, Can you take a picture of the text you are copying, I'm sure it won't.

consider

void setup()
{
    Serial.begin (9600);

    const char *dog = "bark";
    Serial.println (dog);
}

void loop()
{
    Serial.println ("cat");
    delay (1000);           // msec
}

I copied this code from the Dr Duino Course. It is my understanding that it was to practice using syntax. I have proof read it a number of times and as far as I can tell it is a true copy.
I don't know what it is suppose to do other than print dog and bark. The error code I get is at the bottom. If I left something off that I was suppose to add, all I can do beg ignorance. This is my firast post.

The code has some syntax errors...

Have a close look at the post from @johnwasser ... his version has the errors corrected.

It looks like you're missing a line with "void setup() {" that ISN'T in a comment:

//Setup only runs once.
//void setup(){ //notice that this setup() has a different color.

//Comments are meant to explain your code to you and othr people.

//Setup serial Communication.
Serial.begin (9600);//This is the color of the library function.

}//this curly bracket "closes" the setup function.// Put your main code here to run repeatedly;

The example seems to want to show you the difference in coloring between void setup() { as a line of code, and //void setup() { as a comment, but you're missing the "real code" line.

There might be a similar problem with string dog; being inside a comment.

Edit, adding:

Either that, or you just have comment start characters where you shouldn't have.

Whichever, it looks like "copying errors", and we can't say exactly what they are since we don't have access to the source material, and aren't likely to pay the $30+ for a book or course just to be able to check...

I'm sceptical, to say the least, about the soundness of this teaching approach. The syntax is there to clearly convey meaning to the compiler so that the program will do our bidding; it's not supposed to just sit there and do nothing; therefore one ought to be very worried about what the program does with a certain syntax.

I also think insisting so much on colours is somewhat misleading: they are not a part of the language at all; syntax highlighting is a feature of the editor and it's sole purpose is to help the programmer. This is like talking about fonts, page numbering and paper thickness while explaining literature.

I don't want to criticise what I don't know, but let me just say this: there are a lot of sources for learning C++, and many of them are free.

Please post a photo of the tutorial!