Appendix A: Hardware setup

From Bare Metal micro:bit
Jump to: navigation, search

Here's what you will need:

  • At least one micro:bit and micro USB cable. Experiments 20 and 21 involve radio communication, and need two micro:bits.
  • Some form of micro:bit edge connector breakout board that allows jumper wires to be attached to the micro:bit pins. The Kitronik breakout works well, but the edge:bit breakout board from Elecfreaks has the advantage that it can be inserted between the micro:bit and another accessory board.
  • A cheap 24MHz 8 bit logic analyser pod, with mini USB cable and female-to-female jumper wires. These are available from several suppliers on eBay, and googling "24MHz 8ch logic analyser" brings up scores of results.
  • For building programs: either a Raspberry Pi with keyboard and display or a laptop or desktop PC running a recent version of Linux. I tested the software on a Raspberry Pi 3 model B, but other models should work just as well or better. The integrated Raspberry Pi 400 works well too.
  • For use with a Raspberry Pi, an SD card at least 8GB in size. Appendix B 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. The official Raspberry Pi power supplies work well.
  • A handful of additional female-to-female jumper wires for connecting the micro:bit and Raspberry Pi together for some experiments.
  • If using a PC instead of a Raspberry Pi, some experiments require a USB-to-serial adapter that can use 3.3V signals. (Some adapters use only 5V signals: they won't work and may damage the micro:bit.)

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 a Raspberry Pi 3, 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 13 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.
  • Experiment 18 optionally uses the scroll:bit, a matrix of white LEDs that can be controlled over the I2C bus.
  • Experiments 19 and 21 use the :move mini buggy, a two-wheeled vehicle powered by continuous motion servos. Experiment 21 makes a remote control for the buggy, using either a second micro:bit on its own, or the :game zip 64 with more buttons.

Wiring 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.[1] 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.

Channel Colour
0 Black
1 Brown
2 Red
3 Orange
4 Yellow
5 Green
6 Blue
7 Violet
Ground White

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.

The file can be copied to the micro:bit just like any other .hex file.

  1. 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.