Skip to content

Instantly share code, notes, and snippets.

@rudrathegreat
Last active November 24, 2018 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rudrathegreat/ed7db24af713ae8d42444bc0816d19c6 to your computer and use it in GitHub Desktop.
Save rudrathegreat/ed7db24af713ae8d42444bc0816d19c6 to your computer and use it in GitHub Desktop.
Dice Program For BBC Microbit
'''
This code is only meant to be run on the
BBC Microbit because this program uses
a slight deviation of the Original Python.
The language which is being use here is
MicroPython, which is designed for small
microprocessors and microcomputers.
'''
from microbit import *
import random
num1 = Image('00900:09090:00900:00900:09990')
num2 = Image('09900:90090:00900:09000:99990')
num3 = Image('09990:00090:09990:00090:99900')
num4 = Image('00990:09090:99999:00090:00090')
num5 = Image('99990:90000:99900:00090:99900')
num6 = Image('09990:90000:99900:90090:09900')
while True:
if accelerometer.was_gesture('shake'):
display.clear()
number = random.randint(1,6)
if number == 1:
display.show(num1)
sleep(2000)
pass
if number == 2:
display.show(num2)
sleep(2000)
pass
if number == 3:
display.show(num3)
sleep(2000)
pass
if number == 4:
display.show(num4)
sleep(2000)
pass
if number == 5:
display.show(num5)
sleep(2000)
pass
if number == 6:
display.show(num6)
sleep(2000)
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment