microbit
Python Editor for micro:bit
Button Press
Detect Movement
Random Numbers
Gestures
Magic-8
Built-in Images
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
from microbit import *
while True:
if button_a.is_pressed() and button_b.is_pressed():
display.scroll("AB")
elif button_a.is_pressed():
display.scroll("A")
elif button_b.is_pressed():
display.scroll("B")
sleep(100)from microbit import *
while True:
reading = accelerometer.get_x()
if reading > 20:
display.show("R")
elif reading < -20:
display.show("L")
else:
display.show("-")from microbit import *
import random
display.show(str(random.randint(1, 6)))from microbit import *
while True:
gesture = accelerometer.current_gesture()
if gesture == "face up":
display.show(Image.HAPPY)
else:
display.show(Image.ANGRY)from microbit import *
import random
answers = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes, definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to yes",
"Reply hazy try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it"
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful",
]
while True:
display.show("8")
if accelerometer.was_gesture("shake"):
display.clear()
sleep(1000)
display.scroll(random.choice(answers))