David Held
Published © Apache-2.0

Micro:bit Talking Compass

The Talking Compass is a simple project for the Micro:bit written in Python using the built-in compass and Python's Speech module.

BeginnerFull instructions provided1 hour1,085
Micro:bit Talking Compass

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
Amp:bit
×1
adafruit speaker
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Micro:bit Talking Compass

MicroPython
import speech
from microbit import *

compass.calibrate()
while True:
    needle = compass.heading()
    if button_a.was_pressed():
        if needle > 34 and needle < 79:
            speech.say("I am facing north east!")
            display.scroll("NE")
        elif needle > 80 and needle < 124:
            speech.say("I am facing east!")
            display.scroll("E")
        elif needle > 125 and needle < 169:
            speech.say("I am facing south east!")
            display.scroll("SE")
        elif needle > 170 and needle < 214:
            speech.say("I am facing south!")
            display.scroll("S")
        elif needle > 215 and needle < 269:
            speech.say("I am facing south west!")
            display.scroll("SW")
        elif needle > 270 and needle < 304:
            speech.say("I am facing west!")
            display.scroll("W")
        elif needle > 305 and needle < 326:
            speech.say("I am facing north west!")
            display.scroll("NW")
        else:
            speech.say("I am facing north!")
            display.scroll("N")

Credits

David Held

David Held

3 projects • 6 followers
maker teacher

Comments

Add projectSign up / LoginAbout BBC micro:bit