In this project, we'll add sounds to our accelerometer shake game. Specifically, we'll use text-to-speech like we used in the project to command the user to do different actions throughout the game, and let them know if they've succeeded.

You'll need to wire up the Accelerometer as done in previous projects. Here is what your breadboard should look like once the accelerometer is properly wired:

In addition, you'll need the speaker hooked up — refer back to the project if you need help.

Here is what the code for this project should look like at this point (with new changes highlighted with arrows) — it should run similarly to the previous project, but with our new TTS sounds added:

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

Give it a try. The game is still exceptionally easy — you are only requested to tilt left, so it's hard to fail. We'll make this into a real game in the next project.

  1. Can you modify the code so that it only requests (and registers) tilts to the right instead of to the left?

  2. As is, you have to tilt the kit more than about 45 degrees (halfway between flat and fully on its side) before the tilt registers. Can you modify the code to make it more sensitive (less tilt to register) or less sensitive (more tilt to register)?

  3. The speaker is unamplified, and sounds are sometime hard to hear. Can you modify all of the sounds to have an overdriven volume? (Hint: see )