In this project, we will expand on the previous "balancing dot" project by adding movement in the Y direction (up/down) as well as the X direction. Also, we'll keep the dot from moving off the LED Matrix display.

The kit should be wired exactly the same as the previous project. Here is what your breadboard should look like:

Here is the updated code...the code that's new is highlighted with arrows, and we'll discuss that code below:

The new additions we've made are (highlighted with arrows above):

Give it a try...

  1. Can you modify the software so that tilting the kit up causes the the dot to move up instead of down. Likewise, can you reverse the direction the dot moves when tilted down, right and left?

  2. When the dot reaches the edge of the display, instead of having it stay at the edge, can you make it appear at the opposite edge?

  3. If the user moves the dot so that it touches a specific coordinate, can you break out of the while loop?

  4. Secret code: If the user moves the dot so that it touches a sequence a specific coordinates, can you break out of the while loop? For example, say the coordinates are (0,0), (7,7) and (0,3). The user must first move the dot to the lower left corner, then the upper right corner, then position (0,3) on the left side. Once the dot passes through those 3 positions in order, exit the while loop.