Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from microbit import *
- import math
- import random
- # Kitronik INVENTOR'S KIT FOR BBC micro:bit p. 44-47
- # parts used: red 5mm led, 47ohm resistor, male-to-female jumper wire x 2
- goal = 0
- difference = 0
- image = 0
- degrees = 0
- compass.calibrate()
- while True:
- degrees = compass.heading()
- difference = math.fabs(goal - degrees)
- pin0.write_digital(1)
- sleep(difference * 5)
- if(button_a.is_pressed()):
- if(difference < 15):
- display.scroll("Winner")
- goal = random.randint(0,360)
- else:
- display.scroll("Try again")
- goal = random.randint(0,360)
- img = Image("09090:"
- "09090:"
- "00000:"
- "90009:"
- "09990")
- display.show(img)
- goal = random.randint(360)
Add Comment
Please, Sign In to add comment