This Kitronik University
resource is part of the BBC micro:bit partnership
and is an in depth tutorial. We demonstrate how to make countdown rocket pencil case with the BBC micro:bit and Kitronik free D&T sample pack.
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:
In order to create your BBC micro:bit countdown rocket pencil case, you will need:
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
Use the rocket pattern to cut out 3 rocket shapes in the main fabric. Two of these will form the front and back of the rocket, with the third shape being used as the layer the circuit will be stitched onto. This will be sandwiched between the front and back layers. You will need to cut the legs off the circuit layer at the markings on the template.
Cut out the inside pocket for the battery cage.
In the other piece of fabric cut out the front pocket and the small round LED window.
Sew the circuit on the centre layer of the rocket using the Easy Sew LEDs, crocodile clips and the conductive thread as shown in the image above.
To make sure the circuit is in the correct place connect the crocodile clips to the BBC micro:bit and lay it on the circuit layer. Lay the top layer over the top and make sure the BBC microbit can be seen through the window.
On the back of this piece, once you know where the board will be sew the battery pocket into place.
The circuit diagram above explains how the circuit is laid out.
On the front panel take the front pocket and sew the bottom seam to the bottom section of the main window.
Sew a piece of hook and loop fastener to the top of this and a piece of hook and loop fastener just above the top section of the window of the front panel. This creates a flap to give you easy access to the BBC microbit.
Take another piece of hook and loop fastener and place this down one side of the nose cone on the inside of the back piece and sew. The other half of hook and loop fastener will be sewn to the inside of the centre piece and sewn together with the front piece creating an opening for the pencil case.
Position the top piece of the rocket over the circuit and mark and cut a small hole for the LED light to show through. Place the small window over the LED light, getting it centered and make a small cut, again so that the LED light shine's through. Stitch this in place by hand.
Turn the rocket inside out making sure that the front and middle piece are together and back onto the back piece so that you can see the hook and loop fastener.
Do not sew the seam of the nose part on either side, just sew down the seams of the body and the legs both sides. Turn the right way and join the seam on the top nose cone and sew on the right side.
Where the markings are on the template just above the legs machine across the top of the legs (this will stop any pencils falling down into the legs).
Go to the BBC micro:bit website, click "Let’s Code", then look for the MakeCode Editor
and click the button.
Pick a name for your project and you are now ready to write some code!
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.
On Button A pressed:
We use this block to tell the BBC micro:bit what to do when we press its A button. All of our code will be placed within this block and will run in sequence from top to bottom whenever we press the A button.
We use this block to create timed gaps between events in our code. In this case we will use it to ensure that our countdown happens in 1 second intervals. (1 second = 1000ms).
We use this block to display the numerical countdown on the BBC micro:bits LED matrix.
This is the block that we use to switch on and off the external Sewable LEDs. We can select which output pin we are going to write to using the drop down menu. We use its number block to either set the output high or low. (High = 1 or on, Low = 0 or off).
Any text we write into this block will be scrolled across the BBC micro:bits LED matrix.
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.
Inside the ‘on button A pressed’ block we are going to place a show number block and as our countdown starts at 5, we are going to change its value to 5. We can right click this block and select ‘Duplicate’ and a copy of this block will be made, change its value to 4 and repeat this for the remaining numbers.
Now we want to ensure that each step of our countdown is one second and to do that we need to insert a 1000ms ‘pause’ after each ‘show number’ block.
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.
Now, 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!
Edit 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.
Finally, why not change the text at the end of the code for a scrolling image of a rocket!
- Download the paper template here.
- You can download this tutorial as a PDF here.
©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.