12. Accelerometer

As a group go through the tutorial steps on Circuit Playground Express (CPX) Accelerometer Lesson 13. Remember you need to run your program within the Code.org Maker app for this to work.

You will be using the accelerometer to trigger events by moving your CPX. Below is a description of the various components from Lesson 13 that may be helpful to you, followed by the description of the tasks for you to complete today.

Resources from Lesson 13

  1. accelerometer.getOrientation("...") is used to get information from the accelerometer.

  2. "pitch" is used to capture forward/back motion, and "roll" captures left/right rolling. You will have to pay attention to which direction is forward relative to what your program is expecting.

  3. Experiment with code to change your screen color depending on PBX motion.

  4. Turn on particular LED's to indicate when you tilt your PBX in that direction. Again you will have to pay attention to which direction is forward.

  5. Display different text on the screen depending on which direction you tilt your PBX.

  6. Detect and accumulate how many times the board is moved, making a game out of it.

  7. Move a sprite (a "jogger") on the screen every time you shake the board

  8. Move a ball across the screen when you tip your PBX

  9. Maneuver the car to get to the checkered flag without touching any of the red flags.

Today's Tasks:

Use the tutorial steps given above to create a CPX program that does either of the following:

  1. Have the ball move in the direction you tilt the board, similar to step 8 above.

  2. Finish the code so you can maneuver the car to reach the checkered flag in stp 9 above.

Rubric:

The grading criteria for this lab are:

  • 1 point: All group member names are given at the top of your code. Ball or car moves when CPX is tilted.

  • 1 point: Ball or car correctly moves in the direction of board tilt for all 4 directions.

  • 1 point extra credit: Make a game out of it that includes keeping score and resetting the game.

Submitting your Work

Submit the link to your App Lab app you created using this google form.