Skip to content

Programming MicroBit with Python – A Piece of Hardware to learn beginner programming – HOXFRAMEWORK

Posted in VIDEOS

Hello everyone and welcome back,

today we are taking a look at MicroBit – a little piece of hardware used to teach beginners programming. In the video i explain how to use it and program it in python. I use this code


The Code:
-------------------
# Add your Python code here. E.g.
from microbit import *
import microbit
import random
datalist = [
    Image.HEART,
    Image.HEART_SMALL,
    Image.HAPPY,
    Image.SMILE,
    Image.SAD,
    Image.CONFUSED,
    Image.ANGRY,
    Image.ASLEEP,
    Image.SURPRISED,
    Image.SILLY,
    Image.FABULOUS,
    Image.MEH,
    Image.YES,
    Image.NO,
    Image.CLOCK3,
    Image.CLOCK6,
    Image.CLOCK9,
    Image.CLOCK12,
    Image.ARROW_N,
    Image.ARROW_W,
    Image.ARROW_S,
    Image.ARROW_E,
    Image.SQUARE,
    Image.SQUARE_SMALL,
    Image.SQUARE,
    Image.SQUARE_SMALL,
    Image.RABBIT,
    Image.COW,
    Image.PACMAN,
    Image.DUCK,
    Image.HOUSE,
    Image.TORTOISE,
    Image.BUTTERFLY,
    Image.GHOST,
    Image.SWORD,
    Image.SNAKE,
    Image("90009:06060:00300:06060:90009"),
    "WELCOME",
    "HEY",
    "x",
    "X",
    "o",
    "0"
]

scroller = ["WHY ARE YOU LOOKING AT ME O.O","o.o","Stop that","IM A ROBOT","WILL YOU BE MY FRIEND"]

while True:
    display.show(random.choice(datalist))
    sleep(400)
    if microbit.button_a.is_pressed():
        display.scroll(random.choice(scroller))
        sleep(600)
        display.show(Image.HAPPY)
        sleep(600)
    if microbit.button_b.is_pressed():
        display.scroll(random.choice(scroller))
        sleep(600)
        display.show(Image.ASLEEP)
        sleep(600)


--------------

-…To show how MicroBit can be programmed.
-All you have to do is write the code into python.microbit.org editor and download the .hex file which you upload to your Microbit. Then it will run the code.

So that’s it. Thank you so much for watching and have a nice day :).