hi i hacv a problem on the 12 project on the starter kit the yellow light is allway on but when i tap on the buzzer that dont change anythings (sry for the bad english im french) and and the servo doesnt move ``
int knockVal;
int switchVal;
const int quietKnock = 10;
const int loudknock = 100;
boolean locked = false;
int numberOfknocks = 0;
void setup(){
myServo.attach(9);
pinMode(yellowLed, OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(switchPin, INPUT);
Serial.begin(9600);
digitalWrite(greenLed, HIGH);
myServo.write(0);
Serial.println("La boite est ouverte !");
}
void loop(){
if(locked == false){
switchVal = digitalRead(switchPin);
if (switchVal == HIGH){
locked = true;
digitalWrite(greenLed, LOW);
digitalWrite(redLed, HIGH);
myServo.write(90);
Serial.println("La boite est fermée !");
delay (1000);
}
}
if (locked ==true){
knockVal = analogRead(piezo);
if(numberOfknocks < 3 && knockVal > 0){
if(checkForKnock(knockVal) == true){
numberOfknocks++;
}
Serial.print(3-numberOfknocks);
Serial.println("coup restants");
}
if(numberOfknocks >= 3){
locked = false ;
myServo.write(0);
delay(20);
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
Serial.println("La boite est ouverte !") ;
numberOfknocks = 0;
}
}
}
boolean checkForKnock(int value) {
if(value > quietKnock && value < loudknock){
digitalWrite(yellowLed, HIGH);
delay(50);
digitalWrite(yellowLed,LOW);
Serial.print("Coup valide de value ");
Serial.println(value);
return true;
}
else {
Serial.print("Mauvaise value de coup ") ;
Serial.println(value) ;
return false ;
}
}