In this tutorial, students will make their own pencil case from a template from scratch. Then, following step by step instructions, they will connect additional LEDs to the BBC micro:bit via conductive thread and crocodile clips. They will also learn how to programme the device to display a countdown.
BBC microbit Rocket Countdown Pencil Case:You can also customise the pencil case in any way you want, and we have suggested an additional task to encourage students to explore further programming with the BBC microbit.
Learn how to:
- Make a pencil case from scratch.
- Program your BBC microbit to react to an input.
- Light the built in LED display and three additional LEDs via the output pins.
Level of difficulty:
BBC micro:bit Rocket Parts List:
- 1 x BBC micro:bit.
- A Half meter length of red felt.
- 1 x Small piece of black felt.
- 3 x White Easy Sew LEDs.
- Conductive Thread.
- Sewing thread in matching colours.
- hook and loop fastener
- 4 x Crocodile clips.
- 1 x 2xAAA battery cage with JST connector.
- 2 x AAA Batteries.
- 1 x USB to Micro USB lead.
You will also require the following equipment:
- A computer with a USB port and internet access.
- Large eye needle.
- Paper template .
Step-by-step guide to making your BBC micro:bit rocket countdown pencil case
Step 5:MakeCode Editor and click the button. Pick a name for your project and you are now ready to write some code!
Step 6:The code we are going to create is quite simple and will consist of five different block types, shown below. The blocks have been joined together in a random order just to illustrate how they when in use.
Step 7:Our code needs to be able to do two things when we press the A button on the BBC micro:bit; firstly we want to countdown from 5 using the LED matrix to display the countdown and secondly we want to utilise the Sewable LEDs to highlight the last three seconds of the count. First, let's code our five-second countdown.
Step 8:Now that we have our countdown coded we need to insert some more code blocks to what we already have to control how the Sewable LEDs behave. As we are going to use output pins P0, P1 & P2 we need to use the ‘digital write’ blocks to turn each of these on in sequence and then off again. See our preferred solution in the embedded editor below. Starting at 3 in our countdown we want to turn on the first LED, we place the ‘digital write’ block above 3 set it to 1 (high or on) and to pin P0. We need another ‘digital write’ block above 2 and above 1, both need to be set to 1 (high or on) and P1 and P2 respectively. Once our countdown is complete we want to turn off each of the Sewable LEDs. We do this by creating ‘digital write’ blocks for each output and setting them to 0 (low or off). We have now created code to display a countdown on the BBC micro:bits LED matrix and to also light up the Sewable LEDs in sequence and to turn them off again when the countdown completes. For our last line of code we have used the ‘show string’ block to display the blast off message.
Step 9Now, let's try that out! Press Download and after a few moments the code should appear as a download in your browser. If you plug your BBC microbit into a USB port it will show up as a storage device. Simply drag and drop the .hex file you just downloaded onto the BBC micro:bit. Once the file has been transferred, the light on the BBC micro:bit will stop blinking rapidly. Now power up your BBC micro:bit with the batteries, then press the "reset" button next to the USB connector you should see the LED turn on. Then, press A on the BBC micro:bit and the countdown will commence!
Task 1Edit the way the LEDs display during the countdown so that they turn off and on again quickly as it counts down. So the first LED will turn on at the start of the number 3 is shown, it will then quickly turn off and back on again at the same time as the second LED being turned on. Hint 1. Shorten the first pause block after the number 3 by a fraction of a second (20 milliseconds). Then add another digital write block and pause block. Hint 2. Repeat this for the number 2 being displayed. This time turning both the first and second LED off then after 20 milliseconds turn them and the third LED back off.
Task 2Finally, why not change the text at the end of the code for a scrolling image of a rocket!
©Kitronik Ltd – You may print this page & link to it, but must not copy the page or part thereof without Kitronik's prior written consent.