Playing with the BBC Micro:bit (part 1)

In my attempts to be the over eager encouraging dad, I bought my 6 year old daughter a BBC Micro:bit recently in an attempt to spark an interest in programming.

Turns out it was quite a success, as she enjoys creating icon patterns which can then be loaded onto the Micro:bit and displayed with the button presses. While she has got the hang of this and flashing the device herself this seems as much as she wants to do at the minute, which is fair enough.

While she is at school, I thought I would have a little play with the device myself, and I must admit I love this little thing, its such a well thought out device for learning and the tools to program make it so easy.

I built myself a little stopwatch from scratch needing no tutorials, just the block editor. Very basic, button A starts the count and displays the number, button B stops it, Buttons A+B reset it.

That being said, I did run into a slight issue with the block editor, I could not make the “show number” block display a previously set variable as it wanted a number. To get round this I had to switch to the javascript view and manually change the condition to the declared variable. Switching back to the block view it seemed happy with that as the variable name then shows.

input.onButtonPressed(Button.A, function () {
    y = 1
    while (y == 1) {
        basic.showNumber(x)
        basic.pause(1000)
        x += 1
    }
})
input.onButtonPressed(Button.AB, function () {
    x = 0
    basic.showNumber(x)
})
input.onButtonPressed(Button.B, function () {
    y = 0
    while (y == 0) {
        basic.showNumber(x)
    }
})
let y = 0
let x = 0
basic.showString("Go")
x = 0

If you want to try it for yourself my code is here https://makecode.microbit.org/_fkdT3fWkAh6C

I am so impressed with this little device, I would encourage any parent, or even anyone with an interest in programming, as a first step to try it out. You do not even need a physical Micro:bit as the microcode site has a realtime emulator showing exactly what your code does anyway (but it is nice pressing physical buttons)

Related Post

Leave a Reply