Lesson 1
Go to http://microbit.org/.
Click on 'Let's Code'
Under Python click 'Try the beta editor with radio'
Use these simple commands to make your first program:
# Show a scrolling message
display.scroll("Hello!")
# Show a picture
# -> Each line must be 5 characters long (because 5 LEDs)
# -> 0 is off, 9 is completely on. You can have any number inbetween
myImage = Image("00000:"
"09090:"
"00000:"
"90009:"
"09990:")
display.show(myImage)
# Buttons
if button_a.is_pressed():
# do something here
elif button_b.is_pressed():
# do something else here
else:
# do another thing here
Go to your Downloads folder then drag the microbit.hex file onto the MICROBIT drive.
Now try and make a dice. Make it so that when you shake the micro:bit it will show a number from 1 to 6.
while True:
gesture = accelerometer.current_gesture()
if gesture == "shake":
# do something here
Hint: Majority of the built in Python modules work on the micro:bit
import radio
# Radio won't work unless we turn it on
radio.on()
# Send a message
radio.send("message_contents")
# (this preferably in a forever loop):
# get a message (if any)
incoming = radio.receive()
# There is 100 channels which micro:bits can
# communicate on. If you are not doing the same
# thing as someone else you may change channels
# using the following: (at the top of your program)
radio.config(channel=7)