Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. New subscribers only T&Cs apply

Find out more

Challenge 3: The new output in action

Watch how the lights you just coded work in real life
We’re going to add a second display to the micro:bit. This is going to be a strip of lights. To control these lights, we need another menu here, so we need another extension, sometimes called another library. So under Advanced, we have Extensions. If you are connected to the internet, all the extensions will appear. If you’re not, the MakeCode website will still work, but you might not see these extra extensions. So down here is the Neopixel extension, and that’s the one we want.
Once the library has loaded, you’ll see we’ve now got a new menu called Neopixel. Let’s set up our lights.
We’re going to create a new variable called strip, and set it to a strip of Neopixels. And we’re going to connect them to pin zero,
which is this pin on the micro:bit. I’ve only got eight lights. I’m going to change this number 24 to 8. And you’ll see the simulator now has a strip of lights attached to it. So let’s have a play. Let’s see what happens. Let’s start with all of the lights being red.
So you’ll see when the micro:bit starts, after the show the temperature, all of the lights, all eight lights, will go red. Another thing you can do with the strip is you can just change individual colours, so you just change light one or light two or light seven. Let’s try that. So under Neopixel menu, we’ve got another menu called More. And that gives us the option to change one colour at a time. So I’m going to change pixel 0 to orange. And then, after, that we need to add a show because that’s just setting the colour. It’s not actually showing the colour.
So you’ll see there light zero, which is the first light, has got an orange and every other light has stayed red. We can clear the lights, as well. So we could turn them all off if we want to.
We’re going to connect a second output to the micro:bit, a second display, and this is a Sparkle Baton. It’s actually for the Crumble microcontroller,
but it works just as well with the micro:bit. And it’s a strip of eight red, green, blue lights.
So we’re going to connect it up to the micro:bit that’s already been coded. And so each of these lights can be individually controlled, so we need a data line. So I’m going to connect data to this data in line here. And then, we just need to connect power and ground. So just like a normal battery, we’ve got power, 3 volts, going to the plus symbol there. And ground, it’s going to go connecting to the negative symbol. I chose this baton because it’s quite relatively cheap, but it also just works with these clips so you don’t need any extra adapter or anything. So that’s everything wired up.
And we’re going to plug the micro:bit into the laptop because that gives us just a bit more power. And it’s going to show the temperature, and then it’s going to light up depending on that temperature. So let’s see. So it was 22 degrees. And because it’s over 20, all our lights have turned on. So you can see how well that looks, how visual, how bright and cheerful that is. I really like these LEDs for displaying information. So if it was less than five degrees, only the blue lights would come on. And then 10, 15, and now it’s over 20, so we’ve got these red lights.
This can be a bit glary, so you can put diffusers on it using just a bit of paper so it’s less glary to record or to show to people.
And that is a second display for the micro:bit instead of using
the micro:bit screen.

A demonstration of the red, green, blue lights working in real life.

There are lots of different types of light strips, some are 100s of LEDs long. You can even get light matrices – a square of LEDs that you could scroll text across or display animations.

What would you display on your light strip?

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