In this project, we begin creating an accelerometer game that commands the user to shake and tilt the CREATOR Kit in a random order. The challenge is to correctly shake/tilt the kit even as the game gets progressively faster.

For this project, we'll start simple... There will only be one action the user can take: tilt the kit left. In subsequent projects we'll add more functionality to complete the game.

This project will only require the accelerometer. Here is what your breadboard should look like once the accelerometer is properly wired:

For this first implementation of the game, we'll always request that the user tilts the kit left. Then, we'll print out if the user correctly tilted left, or made a mistake (didn't tilt left).

Here's what the code will look like:

Now, let's take a look at what our code is doing:

Try running the program and play around with tilting the kit to the left to get an idea of how sensitive it is to picking up and registering tilts.

  1. The SCORE_NEEDED value affects how sensitive our code is at detecting tilts, and also affects how long it takes to detect the tilt. Try changing SCORE_NEEDED to a high or low value, and see how it affects the tilt detection.