Problems whit a Piezo knock kode.

Hello!

I´m new on programming so i got this Genuino starter kit and accomplish all the tasks include in the kit!
So now i´m was thinking to try to make the knock lock project combine whit the lcd project!

But i cant figure out whats wrong whit my code for the piezo “checkForKnock”.

Sorry if i´m doing this the wrong way but i try too follow the “How to guide”!

My code is:

#include "Arduino.h"


#include <Servo.h>
Servo myServo;

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);



int swichState = 0;
int prevSwitchState = 0;
int reply;


const int piezo = A0;
const int switchPin = 8;


int knockVal;
int switchVal;


const int quietKnock = 10;
const int loudKnock = 100;

boolean locked = false;
int numberOfKnocks = 0;



void setup() {
 
  lcd.begin(16, 2);

  lcd.print("Knacka koden");

  pinMode(switchPin, INPUT);
  
  myServo.attach(9);
  
  Serial.begin(9600);
 
  myServo.write(0);
 
  Serial.println("The box is unlocked");

}


void loop() {
  
  if (locked == false) {
  
    switchVal = digitalRead(switchPin);
   
    if (switchVal == HIGH) {
      
      locked = true;

      lcd.begin(16, 2);
     
      lcd.print("Unlocked");
     
      myServo.write(90);
     
      Serial.println("The box is unlocked!");
     
      delay (1000);
    }
  


  if (locked == true) {
    
      knockVal = analogRead(piezo);


    if (numberOfKnocks < 3 && knockVal > 0) {
    
    if(checkForKnock(knockVal) == true){
      
        numberOfKnocks++;
        
      }
     
      
      delay(1000);
      lcd.begin(16,2);
      lcd.print("fel!");
      
      Serial.print(3 - numberOfKnocks);
      
      Serial.println("More knocks to go");
      
  }
    
    

    
    if (numberOfKnocks >= 3) {
      locked = false;
      myServo.write(90);
      delay(100);
      lcd.begin(16, 2);
      lcd.print("Unlocked");
      Serial.println("The box is unlocked");
      numberOfKnocks = 0;
    }
  }
 }
}
boolean chekForKnock(int value) {
  if(value > quietKnock && value < loudKnock) {
    lcd.begin(16, 2);
    lcd.print("knacka igen!");
    delay(50);
    Serial.print("Valid knock of value");
    Serial.println(value);
    return true;
  }
  else {
    lcd.begin(16, 2);
    lcd.print("Felknack");
    Serial.print ("Bad knock value");
    Serial.println(value);
    return false;
  }
}

And the errorcode i got is: Arduino:1.8.1 (Windows 10), Kort:“Arduino/Genuino Uno”

C:\Users\marcus\Documents\Arduino\sketch_mar14a\sketch_mar15a\sketch_mar15a.ino: In function ‘void loop()’:

sketch_mar15a:82: error: ‘checkForKnock’ was not declared in this scope

if(checkForKnock(knockVal) == true){

^

exit status 1
‘checkForKnock’ was not declared in this scope

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

boolean chekForKnockspelling matters

      locked = true;

      lcd.begin(16, 2);
     
      lcd.print("Unlocked");

The lcd.begin() call needs to happen ONCE, in setup().

Setting locked to true, and then printing unlocked does not make sense.