Approximately 6 weeks ago now, while I was minding my own business (probably prevaricating) I received an email from my regional CAS coordinator asking would I be, in principle happy to be linked up with the BBC and Microsoft to work on a project with some BBC Microbits.
I agreed and within a few hours I received a call from Microsoft, this was the start of what can only be described as an amazing adventure for our school, students and myself that has included a visit to our school from Lord Tony Hall (Director General of the BBC) and Satya Nadella (CEO of Microsoft ) to see the work our students carried out as well as trips to Downing Street and to the House of Commons!
This opened a whole host of ongoing opportunities for us, not least we recently visited 10 Downing Street to kick start the Hour of Code week with Nicky Morgan and David Cameron.
Fantastic as this was these blog posts are not going to focus on these. I will link in to our school’s media page for this. Instead I want to take the opportunity to share some of the classroom methods we developed while working with the Micro:Bit.
In a nutshell…
…is a bare circuit board device, brainchild of the BBC and inspired by the anniversary of the birth of the BBC Micro computer some thirty years ago now. It has been produced in partnership with lots of companies and organisations. Microsoft has been a major partner in it’s development.
My best analogy is that it is like an Arduino with a host of on-board sensors and a very child friendly programming interface. It has an ARM processor and flash memory for storing programs, it contains some very useful sensors;
- an accelerometer for movement, tilting, shaking etc.
- an EM sensor which is generally configured as a digital compass but can be pressed into other uses.
- A thermometer.
- a 5 X 5 display grid of red LED lights.
- 3 accessible GPIO connections which can be configured to work as analogue inputs (via an internal ADC) or outputs (via PWM) or as 3V digital input / outputs.
- A 3V power connection and a ground connection to enable connections to other electronic systems like projects, robots, toys and so forth.
Using the Micro:Bit
As a device on it’s own the Micro:Bit is a great learning device. We spent about two lessons with our year sevens working through the tutorials in the fabulous Quick Start for Teachers guide. In hard copy this “teachers guide” actually works really well in the hands of students. The official Micro:Bit getting started section also has some great resources.
The guide walks you through programming the device and using the sensors, for example making a rock paper scissors game that employs the LED display to show the rock, paper or scissors and the accelerometer to activate the game.
The Micro:Bit really comes in the classroom into it’s own as a device for invention when used in conjunction with other devices like motors and servos. I want to describe some of these methods here and link them to core computing processes and hardware concepts.
Adding other electronics to the Micro:Bit
There are a wide range of ways to connect other devices to the Micro:Bit. For example you can connect your phone or tablet via Bluetooth (there are handy functions included in the API for doing this). There is also an I2C interface buried within the device.
LEDs and even low power relays can be connected and powered directly from the 3 GPIO ring connectors.
For bigger projects, on it’s own the Micro:Bit is not able to supply enough power to drive something like a reasonable size DC motor. I suspect you could drive a really tiny one, perhaps the motor from one of those flying helicopter toys might work but I never tried it. I’ve not actually managed to find a reference for the maximum power output of the Micro:Bit GPIO. It seems to be more than a Raspberry Pi and I believe it also includes some overload protection.
H bridges, Micro:Bits and Motors
If you want to connect anything that needs more juice then one way to do this is to ‘amplify’ the analogue output capability of the GPIOs. The cheapest and simplest way to achieve this is by using a H bridge IC.
We used a L293D. This is a great little microchip which you can buy for under £2.00 and needs barely anything more than a few wires, a separate power supply for the motors and a way to connect it all up, such as breadboard.
This microchip has (input) pins which you can connect directly the Micro:Bit outputs. When the Micro:Bit sends a signal to one of these input pins it is reflected in the output from the L293D, except with more power.
For example, if we want to drive a motor at full speed, we send the value 1024 to the analogue output that’s connected to the L293D. If a suitable motor is connected to the corresponding output it will spin at full speed.
To make it spin at half speed, reduce the value to 512, a quarter speed would be 256 and so on.
We can control up to 3 motors with the three Micro:Bit outputs as long as the motors are all only going to be spinning in the same direction.
(In this simple circuit above, the minimum external power is 4.5v (eg. 3 AA batteries) and the maximum is 7 v. This microchip can actually go as high as 36v but not with the configuration shown above as I have combined all the ‘+ power’ and ‘enables’ for simplicity.)
The same H bridge can be used to control direction, making motors spin forwards or backwards but this requires two signals, one for each direction. As the microbit only has 3 outputs, it can use two of these outputs to control the H bridge and drive a single motor forward and reverse. There is not enough for it to directly control two motors (for turtle robots and the like, although you could drive a single motor forwards and backwards and use the remaining output to control a relay for steering)
The wikipedia entry for this microchip contains a very easy to follow guide for wiring it up if you want to have a go yourself. When I return to school I will also get some of our students to make a how-to video and write-up.
In the meantime here is a couple of videos of it in action, under the control of a microbit. (This was made by me, one handed and in some excitement, sorry about the quality)
You can also see this in action in the video above, it’s being used to control two motors and propellers attached to a model blimp gondola!
The great thing about this method is that you can very easily and cheaply control up to three simple devices. They do not have to be motors,they might also be solenoids or even small incandescent bulbs (for example).
It is possible to use the three outputs and expand these to many more outputs by using the concepts of parallel and serial data connections to another device such as a Raspberry Pi or an Arduino. We did use a method like this to make the little car turtle robot you can see in the video.
We also used the Microbit to control servo motors to make robotic arms and a walking robot (well, not quite but we are getting there).
I will write about these methods in a further blog entry.