Go Down

Topic: Project 12 (Knock Lock) (Read 10472 times) previous topic - next topic



I think there is a problem in the code for project 12 (or the example only works the first time for me).

I lock the box pressing the switch and unlock it knocking 3 times. But when I try lo lock it again pressing the switch, it gets unlocked without waiting for the the knocks. In the communication window, I can see:

the box is unlocked!
the box is locked!
the box is unlocked!
the box is locked!
the box is unlocked!

Upon the variable numberOfKnocks is greater than 3, the code never enters line 39 again, and always satisfies line 46 and, consecuently, it gets unlocked automatically.

If I insert in line number 53 numberOfKnocks=0; (when it gets unlocked), then it works for me.

Anyone can verify it?



Hello everyone, I just realized this project, but the first time it works correctly, but after knocking on it with pressing the button piezo continues unlock. I tried to add a delay () but I get the same problem.
Someone was able to find the solution?
Arduino UNO starter kit.


thank!!!! the new line work perfect  :)

Go Up