In the previous project, we were creating an accelerometer game that recorded each time the CREATOR Kit is tapped. The result of the program was a list of times that the user tapped on the CREATOR Kit.

In this project, we'll make this a bit more useful — we'll create a secret knock. In this case the user will have to tap on the kit with a very specific rhythm. If the their rhythm is reasonably close to our "secret" rhythm, then they've corrected entered the secret knock.

A secret knock could be used to gain access to a room, to start another program, to send a message over the network, or in many other ways!

You'll need to wire up only the accelerometer and speaker as done in previous projects. Here is what your breadboard should look like:

Here is what the code for this project should look like at this point (with new changes highlighted with arrows):

The new additions we've made highlighted above are:

The secret knock in the code above is 2 quick knocks followed by 2 slightly slower knocks: KNOCK KNOCK   KNOCK   KNOCK.

If your timing is off, take a look at the numbers that print out in the Output Window (the first set is your knocks and the second set is the secret knock) and then try adjusting until you get the pattern. It might take a couple tries...

  1. Can you make a more complicated secret knock?

  2. Having trouble replicating the knock in the code? Try doing your own knock, copy of the numbers of your knock from the Output Window back into your code, and then you'll just have to replicate your own knock!