Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- compass.py
- ~~~~~~~~~~
- Creates a compass.
- The user will need to calibrate the compass first. The compass uses the
- built-in clock images to display the position of the needle.
- source: https://microbit-micropython.readthedocs.io/en/latest/compass.html
- """
- from microbit import *
- # Start calibrating
- compass.calibrate()
- # Try to keep the needle pointed in (roughly) the correct direction
- while True:
- sleep(100)
- needle = ((15 - compass.heading()) // 30) % 12
- display.show(Image.ALL_CLOCKS[needle])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement