With the micro:bit finally making its way into our schools and nearly into the hands of young makers around the United Kingdom, we are now starting to see a few teething problems from educators.
One issue that sprang to the foreground involved shorting the GPIO pins which can cause the micro:bit to get rather warm. In normal operation the micro:bit runs absolutely fine and has no issues, but in this particular case the educator had tried to create a traffic light simulator with three LED, red, yellow and green, all of which we directly used with the board, thus causing the LED to short each other out.
— Ben Smith (@ManchesterBudo) 23 February 2016
Normally the micro:bit is used via crocodile clips that connect to the pins at the bottom of the board. But using crocodile clips with components as small as an LED can be quite troublesome.
So the problem we faced was
How can I use the micro:bit with a breadboard to prevent shorts from happening?
In order to properly create a circuit we would need to use something that could secure the components yet still be electrically conductive. So with a little ingenuity and a lot of prototyping we found an ideal solution.
For this project you will need.
Step 1: Trimming the wire
We will need to cut and strip 5 wires which we will use to connect the micro:bit to a breadboard.
Typical colour coding for wiring is to use red to indicate a live voltage, in this case 3V. Black is used to indicate a Ground wire, often referred to as GND.
For wires 0,1,2 pick any colours that you wish.
Using a wire cutter, cut around 15cm of wire for each colour.
Using a wire stripper, strip 1cm of wire from one end, and then strip approx 3cm of wire from the other end.
Step 2: Building the kit
Take 1 of the countersunk machine screws and insert it into 3V.
Place a nylon washer on the machine screw thread.
Take the wire and wrap it around the machine screw, ensure that it wraps around the screw multiple times and that it is not in contact with the micro:bit.
Take a nut and secure it to the machine screw so that it is firmly in place. Do not use any tools for this step as you may damage the micro:bit.
Repeat this step for the remaining pins.
Once complete it should look similar to this.
Step 3: Attaching the breadboard
For this step we will need
When working with hardware and software it is always prudent to test the hardware before you we write any code. Identifying that the hardware is working enables us to quickly move on to writing code that will control the hardware.
To test our hardware we shall use a breadboard which is a semi permanent method of building a circuit. A breadboard has a series of holes arranged into columns and rows.
An LED is a Light Emitting Diode, and when powered it lights up. An LED has two legs, a long leg which is called the Anode, this leg receives power. The shorter leg is called a Cathode and this is connected to Ground, often referred to as GND or sometimes as minus sign (-)
For our first circuit we shall use the wires connected to 3V and GND. Insert the LED as per the image, with the long leg to the top of the board, the short leg of the LED should be inserted a few rows down the board.
Now take the wire from 3V and connect it *in-line *with the long leg of our LED. Now take the wire from GND and connect it*in-line* with the short leg of our LED.
Your LED should now light up.
Congratulations! You have successfully built the kit.
Flashing an LED
Step 1 – Building the circuit
To continue our success, lets build a simple circuit, in fact it’s so simple we only need to alter one wire from our test project.
The red wire that is connected to 3V will need to be removed from the circuit. In its place on the breadboard we shall use the wire from Pin 0 on the micro:bit.
Step 2 – Coding the project
On your computer, open the web browser and visit https://www.microbit.co.uk/create-code
Click on the New Project link in the Microsoft Block Editor section to open a new page, this new page is our coding suite but it is rather blank Looking to the left we can see a series of menus.
Look for the menu labelled “Loops”, left click on the menu and a series of blocks will appear. Using the left mouse button, click and drag “while true” from the menu and drop it into the main window. This loop will run any code inside of it forever.
Look back at the menu, find the Pins menu, left click on it and choose “digital write (0,1) 1 to pin P0”. Drag this block and drop it inside of the loop. By default this block is set to turn on Pin 0\. In coding 1 is equal to on and 0 to off.
Now look for the Basic menu, left click on it and choose the “pause (ms) 100” block, drag it and place it under the previous block but inside of the loop. Milliseconds is abbreviated to ms and 100 is equal to a tenth of a second. To change the pause to 1 second, left click on the value and type in the 1000\.
From the Pins menu grab another “digital write (0,1) 1 to pin P0” and place it under the pause block. This time change the value of “1” to “0” indicating that we wish to turn the pin off.
Finally add another “pause (ms) 100” block under the previous block but still inside the loop.
Your code should look like this.
Step 3 – Getting the code on to our micro:bit
To start this step you will need to attach your micro:bit to your computer using a micro USB to USB lead.
When a micro:bit is attached to a computer it appears as a standard USB flash drive, handily enabling us to copy our code on to it, but where is our code?
To download a version of our code we first need to click on Compile, this will trigger the micro:bit website to compile, which means convert our code into something that the micro:bit will understand, our code and then trigger a download to our computer.
To add that code to our micro:bit we shall now copy the downloaded file onto the micro:bit flash drive.
Your micro:bit will flash a few times as the code is uploaded to the board. Let this process run until complete. Once complete you will see that the LED attached to Pin 0 is now flashing rather fast, indicating that we have successfully created the project.