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:
- Beginner.
BBC micro:bit Rocket Parts List:
In order to create your BBC micro:bit countdown rocket pencil case, you will need:- 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.
- Scissors.
- Paper template .
Step-by-step guide to making your BBC micro:bit rocket countdown pencil case
Step 1:
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.Step 2:
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.Step 3:
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.Step 4:
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).Step 5:
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!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. 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. Pause: 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). Show Number: We use this block to display the numerical countdown on the BBC micro:bits LED matrix. Digital Write: 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). Show String: Any text we write into this block will be scrolled across the BBC micro:bits LED matrix.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. 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.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 9
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!Further Tasks:
Task 1
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.Task 2
Finally, why not change the text at the end of the code for a scrolling image of a rocket!Resources:
©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.
7 comments
Mark Donnison
Hi Jennifer, it was just to allow for ease of removal and reinsertion of the micro:bit. If I were to make one as an item I would probably sew it in place.
Dr. Jennifer Rode
Hi, Why are you using alligator clips which impact the comfort/aesthetics of the final textile? Is this solely to allow the board to be removed, or have you found it difficult to sew the micro:bit in directly without hitting other contacts on the edge connector? Thank you, Jennifer
Karin Høgh
You are welcome – I have snatched this experiment for a Danish ebook with experiments. I tink it is a cool way to start e-textile with micro:bit. Thank you for all your good work.
Mark Donnison
Hi Karin, Well spotted and thank you! Now amended.
Karin Hoegh, PodConsult
There is a typo/mistake in the code – it starts in Step 10 – the numbers in the digital write-block should be as follows: 1-0-1-0-1-0 – your third digital write is wrong – it will not let the middle LED turn on.
Rob Haywood
Nothing has been decided yet, we will announce via our newsletter as soon as we know. Rob
Douglas Logan
I am interested in when and if MicroBit may become available to the General Public and at what cost Yours Douglas M Logan BSc ( Civil Engineering ) + 50 years Computing in Engineering