# Compass: a free micro:bit lesson from Maze Education
# https://maze.education/microbit/lessons/compass
# MicroPython for the micro:bit Python Editor: https://python.microbit.org

# Compass: shows N, E, S or W for the way the top edge points.
from microbit import *

while True:
    heading = compass.heading()
    if heading < 45 or heading >= 315:
        display.show("N")
    elif heading < 135:
        display.show("E")
    elif heading < 225:
        display.show("S")
    else:
        display.show("W")
    sleep(200)
