-
Notifications
You must be signed in to change notification settings - Fork 1
Microbit Cheatsheet
Derek Graham edited this page Feb 23, 2018
·
2 revisions
Always, always, always:
from microbic import *display.scroll('hello there!')display.show(Image.HAPPY)diagonal = Image(
"90000:"
"09000:"
"00900:"
"00090:"
"00009"
) # 0 off, 1..9
display.show(diagonal)brightness = display,get_pixel(x, y)display.set_pixel(x, y, brightness)display.clear()sleep(500) # half a second
sleep(2000) # two secondsif button_a.was_pressed(): # also button_b
message = "You pressed button A"## Accelerometer
x_tilt = accelerometer.get_x()
y_tilt = accelerometer.get_y()
height_off_ground = accelerometer.get_z()if accelerometer.was_gesture("shake"):
message = "Shaking"if pin0.is_touched(): # also pin1 and pin2
message = "You touched pin 0"import music
music.play(music.DADADADUM)
tune = ["C4:4", "D4:4", "R:4", "C4:4"]
music.play(tune)import speech
speech.say("Hello, World")radio.on()
radio.send('shake') # Send a message to others
message = radio.receive() # Read any incoming messages.