The spiritual successor to the original BBC Micro of 30 years ago, the BBC Micro Bit will hopefully inspire a new generation to start coding.

Half the size of a credit card, the board and has an ARM processor, accelerometer and magnetometer sensors, Bluetooth and USB connectivity, a display consisting of 25 LEDs, two programmable buttons, and can be powered by either USB or an external battery pack. There are five handy croc-clip connectors for inputs and outputs, and more through the 23-pin edge connector.

Rocket Fill and Launch Program

posted 4 Jan 2017, 04:14 by Andy Lakin-Hall   [ updated 4 Jan 2017, 04:47 ]

Here's the code I have created for the micro:bit installed in my water rocket as a parachute release mechanism.

This is the second version of the code I created, which previously included a lot mode sounds.

What I discovered was, with the sounds happening at the save time as the servo events, that the sounds seemed to interfere with the servo and make it jitter.

This version strips out all of the sound events until after the servo is deactivated, and so the servo behaviour is much more stable.


Controlling a Servo with micro:bit

posted 18 Dec 2016, 15:25 by Andy Lakin-Hall   [ updated 19 Dec 2016, 00:23 ]

My next project is to control a Servo with the micro:bit.

Micro Servo
I already have a good micro Servo from my Arduino and PICAXE kit, and I've got a wiring diagram of that so I know how to connect it.

The grand idea is to use the micro:bit in a rocket as a parachute release mechanism, particularly as it has accelerometers which can detect launch and apogee. But first to get the micro:bit to test drive the Servo.

Helpfully, Kitronik have a tutorial for this, so I won't be working in the dark.

Here's my circuit. 

I'm using a separate 4.5v supply to power the Servo. The current required for the Servo motor is too much for the micro:bit to do anything else useful, so it's better to use the extra battery.

Here's the code. I've made it so that pressing A moves the Servo up, while B moves it down.

I originally tried moving the Servo to positions 0 and 180, but I found that the Servo jiggled around at the end positions, and I have read about that occasionally being a problem, so I reduced the positions to 10 and 160, and that works better.

Another really interesting tutorial can be found at https://pxt.microbit.org/reference/pins/servo-write-pin. This demonstrates how one range of numbers can be mapped onto another, without a lot of calculations to work it out.

In this example, the number recorded from the accelerometer, which clearly is in the range from -1023 to 1023 is mapped onto values between 0 and 180, which the Servo can cope with.

I haven't actually tried this yet, but I've popped it in here to remind me to try.

Am I up or down?

posted 17 Dec 2016, 07:21 by Andy Lakin-Hall

Here's a second script to detect whether the microbit is lying flat or lifted up.

This script uses a variable, which I have called "pitch"

The purple block rotation (°) pitch won't drop into the IF block. But the variable I defined will.

By experimenting, I discovered that the pitch of the microbit can be sensed from 0° to 90° up and then -90° down, giving a full 180° of rotation. Roll works in a similar way; flat is 0°. rolls to the right count up to 90°, while rolls to the left count down to -90°.

The IF block can be found in the blue LOGIC tab. It can be switched to IF/ELSE by clicking on the blue gear.

The pattern of LEDs is defined from the teal BASIC tab, and I have drawn an arrow pointing up, and a circular target.

Lift Me Up

posted 17 Dec 2016, 06:13 by Andy Lakin-Hall

Here's a little code that makes an arrow appear on the matrix when the micro:bit is lifted up. I haven't worked out a way of getting a good html version of this, so I've just done a screen grab.

This code started in the block editor, but I used the convert function to see the code.


Once the code is finished, there is a handy COMPILE button, which creates a .hex file to download.

The first problem I had was I couldn't get the laptop to recognise the micro:bit. The device was powered from the USB, but the laptop wouldn't recognise it. After a while I worked out that the USB lead I had grabbed was power only, and didn't include the data lines. Once I swapped this for a proper lead the laptop recognised the micro:bit as a drive straight away.

I read that the micro:bit can be used as a USB storage device, and there are two files there already; a DETAILS.TXT file, which gives the technical details about the device, and a .HTM file which links you to the micro:bit website.

Now I found that if the micro:bit was plugged into the USB port I could save my compiled .hex file directly to the device. You can't actually see the .hex file, and I read that you can only have one .hex file on the device at a time.

The problem I found was when I tried to drag and drop the .hex file to the device. I would get an error window and a FAIL.TXT file appears in the micro:bit.

I wondered if there was a problem with where I was saving the file; some mystery problem because of dropbox or something. But the problem recurred no matter where I saved the hex file apart from directly to the micro:bit.

Eventually I read somewhere that you have to disconnect the micro:bit after drag-dropping a hex file. So once I tried that everything worked as expected. So I can store my download hex files on dropbox and share them here,

Beginning to Code

posted 17 Dec 2016, 04:44 by Andy Lakin-Hall   [ updated 17 Dec 2016, 04:45 ]

The micro:bit can be coded in many different ways, depending on what you like.

As I'm familiar with Scratch and block-based programming, so I'm going to try Microsoft Block Editor.

There's documentation to be found here, and a series of tutorials to try too.

My first micro:bit

posted 17 Dec 2016, 03:19 by Andy Lakin-Hall

Inspired by my trip to Horsham Raspberry Jam I decided to take the plunge and try a BBC micro:bit. 

What finally convinced me was the fact that the micro:bit has an accelerometer, so it can detect motion, as well as a built-in display and the ability to drive a servo. This is everything that I've been working on recently with my arduino and Wii Nunchuck for a parachute release system for a water rocket. Maybe the micro:bit will make a better avionics module.

I decided to buy my micro:bit from Kitronik. They'd had a stand at the Jam and I'd met a very interesting gentleman who is developing a new range of interface boards for the device. These look VERY interesting, but they're still in development - and, as I haven't a clue how to program a micro:bit yet, those can wait for now.

I decided to get the Kitronik Inventors Kit, as it has a handy edge connector so all the pins can be accessed, as well as a convenient bread board. The whole package was out of stock when I went to order, but I managed to put together all the bits as separate items, apart from the battery. But I managed to find a switched battery case from microbit-accessories.co.uk.

Kitronk also host a "University Course" full of tutorials to get things started. So I will try out the projects there.

Also of interest there is the instructions for the breakout board which will be essential for more detailed projects.

So enough introductions. Time to try a project!

1-6 of 6