Here's what you will need:
- micro:bit and micro USB cable.
- micro:bit edge connector breakout.
- 24MHz 8 bit logic analyser pod, with mini USB cable and female-to-female jumper wires.
- For building programs: either a Raspberry Pi with keyboard and display or a laptop or desktop running a recent version of Linux. Models 3B and 4B of the Raspberry Pi work well, as should the Raspberry Pi 400. Earlier models may have difficulty with the USB speed needed to use the logic analyser.
- For use with a Raspberry Pi, an SD card at least 8GB in size. Another page gives an overview of the process of setting up the necessary software on the SD card.
- If using a Raspberry Pi, get a good power supply, because it will be powering the Pi itself, the micro:bit, and the logic analyser pod.
- For experiments with the serial port, follow one of the following three options:
- Modify the micro:bit as described below to give access to the serial port pins; or
- Connect an unmodified micro:bit to the UART pins on the Raspberry Pi using a handful of additional jumper wires, and follow an alternative set of instructions; or
- Use a USB-to-serial adapter with 3.3V signals together with a PC or Raspberry Pi to follow the alternative instructions.
The software we use for building programs will work on any version of the Pi, but a Raspberry Pi 2 model B or later is more convenient because it has more USB ports. The screenshots in the book were made on the Raspberry Pi, but the instructions work almost without change on any Linux machine; it doesn't matter whether the machine has an ARM or an Intel processor, because we will be using cross-compiling software that produces machine code for the embedded processor in the micro:bit whatever the host processor may be.
Some of the experiments in the book use various micro:bit accessories. It's perfectly possible to get value out of the book while avoiding these experiments, but the accessories make the programming more fun.
- Experiment 00 optionally uses the scroll:bit, a matrix of white LEDs that can be controlled over the I2C bus.
- Experiments 00 and 00 use the :move mini buggy, a two-wheeled vehicle powered by continuous motion servos. Experiment 00 makes a remote control for the buggy, using either a second micro:bit on its own, or the :game zip 64 with more buttons.
- Experiment 00 needs some kind of neopixel (or zip) display, such as the small one incorporated in the servo board of the :move buggy, or the 8x8 matrix provided as part of the :game zip 64, or an Adafruit RGB neopixel strip, or just a short piece of flexible LED strip stuck on card with some wires soldered to the input end.
Modifying the micro:bit
The V1 micro:bit contains two microcontroller chips: the Nordic nRF51822 main processor which we will program, and a separate Freescale processor that looks after communication with the host PC or Raspberry Pi over USB. The Nordic processor has a serial port or UART that is connected to the Freescale processor, which acts as a USB-to-serial adapter, but the two pins used for this are not brought out to the edge connector of the micro:bit, and that makes it difficult to monitor the communication between them. One solution to this problem is to use alternative pins for experiments with the UART and connect them directly to the Raspberry Pi, and instructions for this are given in the appropriate chapter. Alternatively, it is fairly simple to modify the micro:bit to make the two UART pins accessible by soldering wires to two test points on the board. This will not affect the function of the micro:bit for other purposes. Instructions follow.
- Obtain a two-pin header socket and glue it to the processor board on the right-hand side with a drop of superglue.
- Solder two fine wires to test points TP15 and TP17 on the board, as shown in the diagram.
- Solder the other ends of the wires to the two header pins.
micro:bit version 2On the V2 board, the test points are covered with solder mask to reduce the risk of short-circuits, so it's probably best to use one of the other methods of monitoring serial commnications.
Connections to other pins of the micro:bit can be made using an edge connector breakout, which provides access to 17 of the edge connector pads on the board, together with power and ground. For experiments involving the I2C bus, it's convenient to solder header pins in the remaining two pairs of holes, pins 19 and 20, on the breakout board. These are connected to the two lines, SCL and SDA of the bus.
Connecting the logic analyser
Inexpensive logic analyser pods usually come with a strip of ten female-to-female jumper wires that are long enough to connect conveniently to the micro:bit breakout board. The 8 data channels of the analyser are often numbered from 1 to 8 on a sticker, but the software numbers them from 0 to 7 and colours them according to the standard resistor colour code (see below). It's therefore wise to attach the wires to the logic analyser following the same code, with black for what the sticker calls channel 1, brown for channel 2, etc., so that the colours agree with the software but not the sticker. I use white for the Ground connection, and leave the Clock pin (if it exists) unconnected and the grey wire unused. It's quite a good idea to use a drop of superglue to cement the connectors into a solid block so they stay in the correct arrangement but can still be disconnected from the pod if the need arises.
Restoring the factory firmware
The micro:bit comes with pre-installed firmware that demonstrate the features of the board, which is overwritten as soon as we upload our own programs. To restore the micro:bit to its pristine state, it you can upload a copy of the original
.hex file that is accessible from the following page.
- https://support.microbit.org/support/solutions/articles/19000021613-reset-the-micro-bit-to-factory-defaults (Local copy).
The file can be copied to the micro:bit just like any other
- On some samples of these logic analysers, the clock pin is not connected to anything, on others it is grounded, and on still others it carries a 12MHz square wave. In any case, we have no use for the pin, so it is best left unconnected.