23 lines
557 B
Python
23 lines
557 B
Python
from microbit import *
|
|
import random
|
|
|
|
# Define dice faces
|
|
terning_sider = {
|
|
1: "00000:00000:00900:00000:00000",
|
|
2: "90000:00000:00000:00000:00009",
|
|
3: "90000:00000:00900:00000:00009",
|
|
4: "90009:00000:00000:00000:90009",
|
|
5: "90009:00000:00900:00000:90009",
|
|
6: "90009:00000:90009:00000:90009"
|
|
}
|
|
|
|
def vis_terning(nummer):
|
|
display.show(Image(terning_sider[nummer]))
|
|
|
|
def terning():
|
|
if accelerometer.was_gesture('shake'):
|
|
num = random.randint(1, 6)
|
|
vis_terning(num)
|
|
sleep(1000)
|
|
display.clear()
|
|
|