Science Oxford Logo

Adding more dice options

Using other inputs

The micro:bit has two buttons, as well as the accelerometer. You can use different inputs to roll different types of dice.

For example,

What types of dice would be useful in a game you enjoy?


Adding more if statements

Additional if statements need to be inside your while True loop. They must be indented to the same level as your current if statement.

Take a look at this structure:

while True:
    if accelerometer.was_gesture("shake"):
        roll = randint(1, 6)
        display.show(roll)
        sleep(5000)
        display.clear()
    if button_a.was_pressed():
        display.show("A")
    if button_b.was_pressed():
        display.show("B")