Program a Compass

Micro:bit and battery pack

We need the micro:bit to be contstantly reading the direction and updating what we see on the screen. To do that we need the computer to convert degrees into the compass heading input.

forever
    set degrees = compass heading

So what is north?? Well if we are facing < 45 degrees OR more than 315 degrees then we are "mostly" heading north and we want an N to be displayed on the LED screen.

if degress < 45 OR  > 315
   show  "N" 

Now we need to duplicate this for the other directions:

Now attach your battery back and do some walking to see if this works!

This assignment is based on a project found at https://makecode.microbit.org/projects/compass

Last updated