In the previous project, we started creating an accelerometer application that recorded each time the CREATOR Kit is tapped. One issue, though, was that the program was too sensitive — it recorded too many taps.

In this project, we'll filter out all of those extra taps. To do this, we'll look at any group of taps that were registered close together in a short time period, and assume that they were all part of a single tap.

For this project, we'll only need the accelerometer and speaker. 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):

Here are the new additions that we've made to the code and highlighted above:

When you try this, you'll see three sets of numbers printed in the Output Window. The first is the list of raw taps, the same as what we saw in the previous project. The second set of numbers is the filtered taps, which removes all the taps close in time, and leaves us with the start time of each new tap. Finally, we have the relative tap timing, which tells us the amount of time between each successive tap.

  1. We used the arbitrary number 20 to filter out extra taps. If the number is too small, then it we won't filter out all of the extra taps. How small can this number be so that when you tap the kit once, you still see only one filtered_tap_ticks?

  2. You can also increase the tap filter number (20). However, if the number is too large, then two fast taps in a row will only be recognized as one tap. How high can you increase the number so that the program still recognizes individual taps when you record two fast taps in a row.