CHARGE for micro:bit attached to a wrist displaying 2 degrees.

Introducing the Compass

Never get lost with your micro:bit in compass mode! This project will show you how to display the micro:bit’s bearing from magnetic North in degrees. You can also boost your comfort and range using a CHARGE pack for your micro:bit!

What you need:

With CHARGE for micro:bit

Without CHARGE

  • micro:bit (V1 or V2)
  • USB cable
  • Chromebook, laptop, or desktop
  • power bank or battery pack
  • wrist strap, clips, or elastic bands

Code your Compass:

  1. Open makecode.microbit.org
  2. Plug in and pair your micro:bit
  3. Input drawer: add “on button A pressed”
  4. Basic drawer: add “show number 0” 
  5. Input drawer: grab the “compass heading (°)” block and drop it onto the 0 in “show number 0”
  6. Download your code:
    • When you press button A, you’ll be told to “Tilt to fill screen,” hold the micro:bit flat or parallel with the ground and then tilt the micro:bit until all the LEDs are lit up. 
    • You have now calibrated the micro:bit and now when you press button A, it will display the direction in degrees.
    • Remember to hold the micro:bit flat to get the most accurate results!

Or experiment with the finished code here:

Use the Compass:

Now attach the micro:bit to your wrist, turn on the CHARGE and check which direction you’re facing! Remember that North is 0 degrees and goes up clockwise.

Graphic of directions with degrees. North 0°, North East 45°, East 90°, South East 135°, South 180°, South West 225°, West 270°, North West 315°

Make it better:

Now if you didn’t want to try and remember how many degrees each direction is, can you think of a way to display a letter or two instead of the number? Hint: IF statement codeblocks.