Having had a couple of micro:bits for a while I thought it about time I did something practical with them and inspired but an article in the May/June 2017 issue of Elector Magazine , I decided to try out the C/C++ mbed developer platform. mbed is a online set of developer resources for IoT devices based on ARM microcontrollers, which includes the BBC micro:bit.
I plan to update this page as I work on the project, and will make the code and any custom hardware circuits available to download from my github site. I hope at some stage to also publish the complete s/w builds directly via mbed, but am struggling a little with this at the moment …
The starting point
My starting point was to get use to compiling code to the micro:bit via the mbed environment, using the elector instructions I managed the usual ‘Hello World’ scrolling display. There are a few typos / omissions in the article but, with a little looking at the online help managed to successfully compile and copy some basic programs on the microbit. Interestingly it proved easier to setup a Raspberry Pi to run mbed than windows 10 – mainly because the drivers needed for the USB side are already installed with Linux.
First working version
Having got the basics working I wrote a bit of code to drive output 0 as a analog line up and down using the A & B buttons. Once I had this working I built a simple driver using the SN754410 Quadruple Half-H Driver IC. you can see this working on this YouTube clip.
Remote control rev 1
The next stage was to get the 2 micro:bits talking to each other. I started here with some example code from the mbed site, and after a few false starts was able demonstrate basic remote control – as you can see on this video clip. The s/w uses the micro:bits built-in 2.4GHz radio module configure for simple micro:bit to microbit communications [rather than the more usual Bluetooth standard] . It is worth noting this is a very simple protocol and does not include any security – so any suitably configured micro:bit in range will receive messages. The code for is on my github site. Importantly for ‘radio’ function to work you have to inhibit the inbuilt Bluetooth functionality by adding a line to MicroBit.h include file – this is explained in more detail on the ‘micro:bit runtime site’
The next stage
Having got a basic working circuit on a breadboard the next stage for me was to transfer the design to something a little more permanent. for something like this I would usually build it on a ‘stripboard’ but the edge connector on the micro:bit makes this quite difficult to do. Instead I designed a simple PCB and got it manufactured by Ragworm. You can down load the final schematic from my github. There is lots of ‘stuff’ on the 754410
on the web so I will not repeat it here but in terms of the interface to the micro:bit I use ‘output 0’ setup for PWM analog to drive the input stage of the 754410 and a spare IO line for direction control. Although I only needed a single circuit including a second channel made sense as the 754410 can drive 2 channels.
June 2017
Having checked out the PCB fully, I have gone back look at the ‘remote control’ micro:bit. Here I am planning to look at what makes the most user friendly speed control interface. initially I have set it up to be controlled by the accelerometer output where full speed is the 12 o’clock position and stop is 3 to 9 o’clock. I have also included a speed lock function and direction change using the buttons. While this works fine I am not sure how good it will be in practice for accurate train control. Next I plan to try a more ‘traditional version with a rotary or slider control.
You can see a short video of the accelerometer control version here and you can you can find the code on my github.
While not planning to actively sell the PCB, most likely I will have some spare so do let me know if you want to buy one rather than get your own made.