Activity 03.04: Gravity Detector

Goal: Create a program that displays acceleration.

Success Criteria:

  • The micro:bit runs the program with no errors
  • Your program is an infinite loop that displays acceleration in X, Y and Z directions in the console

Task:

  • Take a look at this demo
  • Use the documentation
  • Fill in the blanks below
  • A Tricky Challenge: Have the program display UP or DOWN based on if the device is upright or upside down – you’ll need to use if statements! Remember: When the device is upside down, the Z value is positive (greater than 0).

Extension:

  • What happens to the X value when you tilt the device from side to side?
  • What happens to the Y value when you tilt the device forward and backward?
  • What happens to the Z value when you flip the device over?
Scroll to Top