Arduino Forum

Products => The Arduino Starter Kit and Basic Kit => Topic started by: swapper on Jan 08, 2013, 06:54 pm

Title: Project 12 (Knock Lock)
Post by: swapper on Jan 08, 2013, 06:54 pm
Hi.

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?

Thanks.
Title: Re: Project 12 (Knock Lock)
Post by: nass on May 03, 2013, 10:02 pm
I have the same
Title: Re: Project 12 (Knock Lock)
Post by: alex27riva on Sep 04, 2013, 08:52 pm
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?
Title: Re: Project 12 (Knock Lock)
Post by: Comme on Sep 08, 2013, 06:56 pm
Hi!

Here is how i fixed it:

http://forum.arduino.cc/index.php?topic=175831.msg1383787#msg1383787 (http://forum.arduino.cc/index.php?topic=175831.msg1383787#msg1383787)
Title: Re: Project 12 (Knock Lock)
Post by: jhenriquez on Feb 21, 2015, 06:23 pm
thank!!!! the new line work perfect  :)