Using the BBC micro:bit as an input device


As discussed in ‘the anatomy of the micro:bit‘, the micro:bit has many functions which enable it to carry out a range of tasks, from measuring ambient temperature using its temperature sensor to using its Bluetooth capabilities to take pictures with your phone – the possibilities are endless!

The BBC micro:bit can be used in your classrooms to bring computing alive for children, making it a subject that is interactive, engaging and fun. Therefore, this page explores how we can connect the micro:bit to a program such as Scratch, in order to use it as a game controller. This specific concept is outlined in the KS2 National Curriculum for computing which states that children should “design, write and debug programs” which could be controlled or simulated by a physical system, such as the micro:bit.

Using Scratch in the classroom


Firstly, what is Scratch?

Scratch is a visual programming language which gives children the opportunity to program interactive media such as games and animation that can be published online and shared with Scratch’s online community.

Why should we encourage Scratch to be used?

Scratch is a beneficial resource that is accessible to pupils of all ages, helping them to think creatively, work collaboratively and work systematically whilst improving their knowledge of how digital systems work, allowing them to apply this knowledge through programming.

How can we support children in learning about this programming language?

It is important to recognise that children are not born with vast amounts of knowledge around physical devices, therefore they cannot be expected to simply log on to Scratch and know what every block on the program represents and controls, nor will they know how to instantly create sprites, program them or how to cause certain outcomes through algorithms. Having said this, the National Curriculum states that we, as teachers, should provide children with resources that will support them in developing their knowledge of digital systems, how they work and how this knowledge can be applied to numerous situations. This means that we need to provide children with activities and resources that are adaptable to support children in building this knowledge, in turn, helping them to learn how to write simple, unambiguous algorithms, how to debug simple programs and how they can use logical reasoning – all key concepts that Scratch programming language can develop when used in the classroom.

Scratch blocks unplugged

Supporting children in sequencing, debugging and algorithms

Using unplugged activities within the classroom can support children in developing their computational thinking, without the need to involve computer hardware or software.


Activity idea: Sequencing real life actions

Blank Scratch blocks downloadable here.

This activity can be used to support children in creating algorithms which can be used to instruct their partner, using different commands. This is achieved through the use of blank Scratch blocks on which they can write their own commands, based on real-life actions, like the example to the right.

This activity can support children in developing their computational thinking and the image to the right shows what a child’s thought process may be, where you can see that the initial image shows the blocks that are provided, and the algorithm which has been made as a result. Children are able to test out these algorithms, where they may notice that it is difficult to carry out the algorithm (pictured bottom left), causing them to debug and then construct code which will make this it run more smoothly, demonstrated in the bottom right image which uses ‘wait’ blocks. This activity also supports children in sequencing, where they are able to manipulate the blocks.

By allowing children to use an activity like this, they are able to be introduced to the idea of Scratch blocks, causing them to become familiar with algorithms, before applying this knowledge to allow them to understand how they can be implemented as programs on digital devices.


Activity idea: Unplugged Sequencing using Scratch blocks

The activity that is demonstrated in the video to the right moves learning forward for pupils, where they are able to use real Scratch blocks.

This activity furthers pupils understanding of sequencing where they are required to move the Scratch blocks and piece them together, creating algorithms that are sequenced in a particular order. This activity also supports children in logical reasoning, where they are able to consider the result of the placement of different blocks.

After having constructed their algorithms, children should be given the opportunity to transfer them to Scratch, where they are able to test them and ensure that their sequences are correct. After having inputted their algorithms into Scratch, children will be able to see whether they work successfully – if they do not, children can try to debug the algorithms, where they have to identify errors in the code and correct it so that the algorithm carries out the goal that was initially intended.

Using the BBC micro:bit in the classroom


The micro:bit is an example of a physical device that requires specific algorithms to carry out commands. For pupils to be able to successfully use the micro:bit as a controller for a game, they need to have some prior understanding of Scratch programming language, how blocks can be put together to form algorithms and an understanding of repetition and sequencing, which reinforces the points above which discuss why children should be taught to code using a program such as Scratch.

Detailed below is an example of a series of lesson outlines that could be executed around the BBC micro:bit, to support pupils in using it as a game controller. These outlines are more specific to KS2 pupils, yet they can be adapted to support younger children.

Please note: these outlines are an just one way of how the micro:bit can be used, and in actual fact, there are endless activities based around this physical device that can be used to support children in developing their computational thinking.

Lesson Number Lesson Outline
1: Familiarising pupils with Scratch and the micro:bit

Activities such as Scratch blocks unplugged can support children in their understanding of Scratch – these demonstrations can be found at the top of this page.

For activities that can support children in learning about the micro:bit and its functions, click here.

2: Exploring the micro:bit through programming with the BBC micro:bit Javascript Blocks Editor.
3 part 1

3 part 2:

Play Scratch games that are designed for the use of a keyboard and mouse.

Play Scratch games that are designed to be used with the Micro:Bit, where they require its features to be used such as the tilt, buttons and shake.

4: Design a simple game that uses computer inputs such as: the space bar, mouse clicks and arrow keys.
5: Begin to create a game using standard scratch blocks.
6 part 1:

6 part 2:

Finish creating game and test its functions to ensure that it works correctly.

Change input codes required on the computer to input blocks that are from Scratch’s micro:bit block extensions. Encourage children to utilise all of the features of the micro:bit necessary for their game to be effective

7: Exhibit games in the classroom.

For more details on what these sessions for offer, please click here, where you will be able to download a plan which details seven different sessions, their lesson objectives/outcomes, why tasks like this should be used and how these lessons make connections with the National Curriculum.

Alternatively, the micro:bits website has a range of activities that children can complete.

Using the BBC micro:bit with Scratch


The micro:bit is a useful physical device that can be used in accompaniment with Scratch programming language to allow children to see how precise codes can control a physical device.

As previously mentioned, the micro:bit can be used to control a game on Scratch, causing it to be an input device where data like the micro:bit’s tilt angle and buttons presses are being sent to the computer and received by it, causing the computer to react by triggering certain codes within the game. Additionally, the micro:bit can also be used as an output device, where data is sent from the computer, causing the micro:bit to react. For example, when the micro:bit is connected to the computer, the LED screen produces a C.

Micro:bit as an input device

The video below demonstrates how the micro:bit can be used to control a simple game on Scratch. The game created is called ‘The Flying Dragon’ and the aim of the game is for the player to use the micro:bit as a controller to guide the dragon through gaps in the rocks without hitting them or the ground. In order for the dragon to move, the micro:bits accelerometer is used to detect changes in the movement of the device, meaning that it can pick up how the micro:bit is being tilted in order to trigger code that causes the dragon to move steps in different directions. Scratch could also be used to program the micro:bits A button which causes the dragon to flap its wings, and its B button which causes the dragon to breathe fire – these buttons trigger specific code when pressed.

Micro:bit as an output device

The micro:bits 5×5 LED Matrix allows it to be an output device, where algorithms can be built on the computer (via a programme such as Scratch) and sent to the Micro:Bit, causing it to display letters, numbers or symbols.

The video’s below demonstrate how this is possible, simply through the micro:bit extension block on Scratch, known as ‘display’. In the ‘title’ video, the micro:bit displays ‘Flying Dragon’ when the green flag is clicked. In the ‘score’ video, the micro:bit displays the score each time a point is gained within the game, causing numbers to be produced: ‘0, 1, 2, 3…’. In the ‘game over’ video, when the dragon hits the rocks or the ground, the Micro:Bit recognises this and displays ‘game over’ on its screen.

Allowing children to explore how a game like this works can support children in developing their understanding of computers, as well as helping them to appreciate the fact that algorithms play a fundamental role within computing. However, the opportunity to play such games does not suffice on its own, therefore pupils need to be introduced to ways that this game can be used to support their understanding of the fundamental principles and concepts of computer science: abstraction, logic and algorithms.

Using the micro:bit and Scratch together can support children in understanding the key concepts that relate to programming and computational thinking. Not only this, but providing children with activities based around a Scratch game can provide them with a meaningful context, engaging them, inspiring them and making them want to develop their understanding of computers to solve problems. Some example activities are: expressing algorithms as flowcharts, identifying code, creating algorithms, fixing code and changing the difficulty of games.

 


Print Friendly, PDF & Email