Skip main navigation

Hurry, only 5 days left to get one year of Unlimited learning for £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

Challenge 3: Create a new output

Challenge 3: Create a new output

From the previous challenges, you’ve learnt how to deal with input from the user, connect a speaker to the micro:bit, deal with input from a sensor, edit that data and display data on the micro:bit screen.

We’re onto intermediate challenges now. The micro:bit screen is useful but it’s also very small. What if we wanted to display our information to people from a distance? Or if we wanted to display a lot of information at once. We’re going to add another output to the micro:bit to use as a display.

For this challenge we’re going to display data from the real world in lights. We’re going to take the temperature of the room and display it as different coloured lights.

In the next step I’ll show you how to add a new library to the micro:bit to control multi-coloured lights.


Libraries are very common in coding. A library contains code that someone else has written for a specific reason. There are libraries for dealing with dates in code, libraries for creating graphs and libraries to control hardware. In this case, we want to add a library to control hardware. We don’t have to know exactly how the hardware works, the library will do that work for us. It gives us simple to use code to control the hardware.


This is the hardware we’re going to use:

  • A strip of eight lights
  • three crocodile/alligator clips

The strip contains eight red, green and blue lights. Each light can be controlled individually or the entire strip can be controlled. The lights can change to any colour combination of red, green and blue.

Hardware neededHardware needed
(Click to expand)


We have 8 lights. I’m going to create 4 zones of temperature. Two lights will represent each zone. If it’s cold out, I want the lights at the bottom of the strip to turn on blue. If it’s warm out, I want all the lights to turn on.

Our plan is quite complicated, so let’s draw it out in more detail.

When the temperature is greater than 0 degrees, lights 0 and 1 will be blue

When the temperature is greater or equal to 5 degrees, lights 2 and 3 will be orange

When the temperature is greater or equal to 10 degrees, lights 4 and 5 will be green

When the temperature is greater or equal to 15 degrees, lights 6 and 7 will be red

Let’s take 7 degrees as an example. If it’s 7 degrees, what lights will come on?

Answer: Lights 0, 1, 2 and 3 will be on. 0 and 1 will be blue. 2 and 3 will be orange.

When it’s over 15 degrees, all of the lights will be on and coloured.

With such complicated code, I would write this in a text based language like JavaScript or Python.

This article is from the free online

Build a Physical Computing Prototype

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now