Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from microbit import *
- import random
- NUMBER_COUNT = 0
- NUMBER_LIST = [
- Image("70000:70000:70000:70000:70000"),
- Image("77700:00700:77700:70000:77700"),
- Image("77700:00700:77700:00700:77700"),
- Image("70700:70700:77700:00700:00700"),
- Image("77700:70000:77700:00700:77700"),
- Image("77700:70000:77700:70700:77700"),
- Image("77700:00700:00700:00700:00700"),
- Image("77700:70700:77700:70700:77700"),
- Image("77700:70700:77700:00700:77700"),
- Image("70777:70707:70707:70707:70777"),
- Image("70700:70700:70700:70700:70700"),
- Image("70777:70007:70777:70700:70777"),
- ]
- DI_NUMBER = len(NUMBER_LIST) - 1
- DISPLAY_NUMBER = NUMBER_LIST[DI_NUMBER]
- def change_di(di_number, incr_number):
- sleep(250)
- return di_number + incr_number
- while True:
- if accelerometer.was_gesture("shake"):
- display.clear()
- sleep(500)
- random.seed()
- random_roll = random.randint(0, DI_NUMBER)
- DISPLAY_NUMBER = NUMBER_LIST[random_roll]
- else:
- if button_a.is_pressed() and DI_NUMBER > 1:
- DI_NUMBER = change_di(DI_NUMBER, -1)
- DISPLAY_NUMBER = NUMBER_LIST[DI_NUMBER]
- if button_b.is_pressed() and DI_NUMBER < int(len(NUMBER_LIST) - 1):
- DI_NUMBER = change_di(DI_NUMBER, 1)
- DISPLAY_NUMBER = NUMBER_LIST[DI_NUMBER]
- display.show(DISPLAY_NUMBER)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement