I set up to program the BBC Micro:bit (which I’ll call the microbit from now on) in C/C++ under Linux. I’ve been using micropython to program the boards up to now, but want to leverage the increased performance that using C can give and some of the C libraries that are available for e.g. encryption.
There is good documentation on the Lancaster University microbit github page:
I installed the offline tools as I spend a lot of time working at sea where you can’t always rely on having an internet connection. I got a demo compiled and loaded by following the instructionso n the Lancaster University github site. Now it was time to write my own code. I had a little trouble getting this going, so here’s what I had to do to get my first program compiled and loaded. I did this by modifying the structure of the examples directory that was created by following the github instructions.
I downloaded the github repository linked above into
Initially I made a new directory under:
Whenever I ran ‘yt build’, I got a weird error referring to one of the bluetooth example programs. Plus yt build took longer than I thought it ought to. So…..
Put these folders one level above this folder. Only put the main.cpp file into
I copied the file:
to the microbit. After waiting for the flashing LEDs to stop, it worked!
The microbit unmounts itself each time that you load a new hex file. So using the bash script that I detailed in an earlier blog to quickly mount the microbit is a time saver.
This is a quick way of getting started by building on top of the examples directory that most folk will start with.
disclaimer: I loiter in the same department as the authors of the C/C++ BBC Micro:bit repository.