Step 1: Make it
What is it?
Turn your micro:bit into a simple compass which shows its bearing from magnetic North in degrees.
How it works
- Your micro:bit has a built-in compass sensor called a magnetometer. You can use it to measure the Earth’s magnetic field and use it as a compass.
- When you first use the micro:bit compass you have to calibrate it – a little game appears on the screen where you have to tilt the micro:bit to light up every LED, then you’re ready to go.
- When you press the button A input, the micro:bit takes a reading from the compass sensor and shows the device’s numerical compass bearing on the LED display output. Point the micro:bit North and you should see a reading of 0 degrees.
What you need
- micro:bit (or MakeCode simulator)
- MakeCode or Python editor
- battery pack (optional)
- a planet with magnetic poles to stand on – for example, Earth!
Step 2: Code it
Step 3: Improve it
- Add another button to recalibrate the compass.
- Have the micro:bit make a sound when it’s pointing in a particular direction – this could be useful to help navigation when you can’t look at a display or for people with impaired vision.
- Make the micro:bit display letters or arrows to show if it’s pointing North, South, East or West.