Compass with CHARGE Power Pack
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
- micro:bit (V1 or V2)
- USB cable
- Chromebook, laptop, or desktop
- CHARGE w/ wrist strap
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:
- Open makecode.microbit.org
- Plug in and pair your micro:bit
- Input drawer: add “on button A pressed”
- Basic drawer: add “show number 0”
- Input drawer: grab the “compass heading (°)” block and drop it onto the 0 in “show number 0”
- 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.
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.