Merge branch 'update' of https://gitpot-lerking.servehttp.com/CodingPirates/python-microbit into update
This commit is contained in:
22
terning.py
Normal file
22
terning.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from microbit import *
|
||||||
|
import random
|
||||||
|
|
||||||
|
# Define dice faces
|
||||||
|
dice_faces = {
|
||||||
|
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 show_dice(number):
|
||||||
|
display.show(Image(dice_faces[number]))
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if accelerometer.was_gesture('shake'):
|
||||||
|
num = random.randint(1, 6)
|
||||||
|
show_dice(num)
|
||||||
|
sleep(1000)
|
||||||
|
display.clear()
|
Reference in New Issue
Block a user