Problem with code of example 12 from the guide book

Ciao a tutti,

I am having a problem with code in the example 12 from the guide book: if I try to compile the code I get this error.

Arduino:1.8.4 (Linux), Scheda:“Arduino/Genuino Uno”

/home/ettore/Arduino/Knock_lock/Knock_lock.ino: In function ‘void setup()’:
Knock_lock:16: error: ‘myServo’ was not declared in this scope
myServo.attach(9);
^
Knock_lock:21: error: ‘begin’ was not declared in this scope
Serial:begin(9600);
^
/home/ettore/Arduino/Knock_lock/Knock_lock.ino: In function ‘void loop()’:
Knock_lock:34: error: ‘myServo’ was not declared in this scope
myServo.write(90);
^
Knock_lock:40: error: ‘KnockVal’ was not declared in this scope
KnockVal = analogRead(piezo);
^
Knock_lock:42: error: ‘chekForKnock’ was not declared in this scope
if(chekForKnock(knockVal) == true){
^
Knock_lock:43: error: ‘numberOfKnocks’ was not declared in this scope
numberOfKnocks++;
^
Knock_lock:45: error: ‘numberOfKnocks’ was not declared in this scope
Serial.print(3-numberOfKnocks);
^
Knock_lock:48: error: ‘numberOfKnocks’ was not declared in this scope
if(numberOfKnocks >= 3){
^
Knock_lock:50: error: ‘myServo’ was not declared in this scope
myServo.write(0);
^
/home/ettore/Arduino/Knock_lock/Knock_lock.ino: In function ‘boolean checkForKnock(int)’:
Knock_lock:61: error: ‘quietKnock’ was not declared in this scope
if(value > quietKnock && value < loudKnock){
^
exit status 1
‘myServo’ was not declared in this scope

Questo report potrebbe essere più ricco di informazioni abilitando l’opzione
“Mostra un output dettagliato durante la compilazione”
in “File → Impostazioni”

I think I wrote the code in the right way but I cannot find the error.

ettorenoferini:

Knock_lock:21: error: 'begin' was not declared in this scope

Serial:begin(9600);

That should be:

Serial.begin(9600);

The other errors are probably caused by other miscellaneous typos you introduced while typing the code in.

I'm going to let you in on a secret:
You don't need to type in the code for those projects. You can find them all in the File > Examples > 10.StarterKit_Basic menu!

Now some will say that the process of typing the code is important for learning. I disagree. In fact I think it just causes a lot of confusion because most people end up introducing typos that make the code not compile. Instead, put the time you would have wasted typing code and then fixing all your typos into reading through the code line by line and thoroughly researching every bit of code you don't understand. Once you understand the code try making some modifications to it, then verify the result matches your expectations.