Try an Existing Tilt Compass

A "tilt compass" is a name we are giving to a device that points downwards (instead of north).   It uses the micro:bit modules accelerometer in place of its magnetometer.  In contrast to a magnetometer used to sense the earth’s magnetic field for compass apps, an accelerometer measures force from acceleration, but it also measures gravity’s force.  It can use gravity’s force to measure which way the accelerometer is being tilted.  A tilt compass can use the same hands the micro:bit uses to display north (and clock times from 1 to 12) to display the direction the micro:bit is being tilted.

In this activity, you will test an existing tilt compass application.   By getting familiar with the tilt compass code and behavior, you will have a benchmark for guiding an AI through writing a similar application.

How to Use the Existing Tilt Compass App

When you test existing tilt compass app with the next example script, you will hold the micro:bit like a steering wheel.  Not flat on a table, more like flat against a wall, so the LED matrix is facing you.  As you rotate the micro:bit module, the line on the LED display will point downward. 

There are only twelve directions it can point, so it cannot point perfectly downward at every  any angle, but it will be pretty close.

You don’t have to hold the micro:bit perfectly vertical either.  If you hold it flat and tilt just a little, the LED display will still point in the downward direction, that is, the direction a small ball would roll off its surface.  To see how this works:

  • Watch the clip and pay close attention to the micro:bit (actually, ignore the cyber:bot robot).  
  • See how the clock hand on the micro:bit display always points down as the micro:bit is tilted?

Now, you are ready to load the tilt compass app into the micro:bit and test it.