Skip to content

Selection and sensors

Introduction to selection & sensors

If you are teaching selection and sensors, use this guide to introduce micro:bit to your teaching.

The projects highlighted below explore the micro:bit’s inputs by using its light and sound sensors, and the accelerometer to activate outputs. It builds on understanding developed in the topic inputs and outputs and develops programs to use inputs to control outputs through the use of selection.

The projects are split into different ability levels so you can find the projects to suit your students: Getting started, Next steps and Aiming further - for more confident users.

Using micro:bit to teach the concept

Programming with the micro:bit is a great way to introduce students to develop their understanding of selection. Their understanding of how inputs can be used to trigger events is also built on when introducing pupils to sensors.

Through their exploration of the micro:bit’s inbuilt sensors, such as light, sound and temperature sensors, students will appreciate that sensors are constantly sensing changes in environmental conditions and that programs can be constructed that use these changes as a trigger.

Using the micro:bit’s sensors and replicating real-life examples supports students’ learning of selection and allows them to consider the differences between programs that respond to an input, such as pressing a button, and those that respond to a change in environmental conditions. They'll also learn the need to carry out the associated action every time this condition is met.

Developing students skills

Exploring selection in these purposeful contexts provides the opportunity for students to be introduced to control systems.

By constructing programs where outputs are generated as a result of changes in environmental conditions such as lights turning on when the light level falls below a certain value or alarms sounding when movement is sensed, students are creating actions that are carried out in the real world.

This will foster a greater appreciation for the roles that computers, particularly control systems, play in their everyday lives. Furthermore, all these purposeful and engaging learning opportunities can be provided to students using the micro:bit’s inbuilt sensors.

What students will learn

This set of micro:bit projects for teaching and learning selection and sensors supports students’ understanding of the following concepts.

Concepts covered

This topic develops the knowledge, skills and understanding of the following programming and computational thinking concepts

Programming: Debugging, Selection, Sequence, Loops / repetition

Computational thinking: Algorithms, Abstraction, Decomposition, Logical thinking, Pattern recognition

Computer systems: Control, Inputs and outputs, Simulation.

Find out the primary curriculum links for this set of micro:bit projects.

Getting started projects

If you're just getting started with micro:bit, these projects are perfect for teaching the selection and sensors.


This project can be used to consolidate pupils’ understanding of inputs and outputs.

What students will learn

It introduces pupils to one of the micro:bit’s sensors (temperature) and illustrates that the sensors are constantly recording changes in their environment. It also introduces the idea that the data recorded by the sensors can be used in programs as the micro:bit uses the LEDs to display the current temperature.

Sunlight sensor

This project introduces pupils to selection by using the light sensor.

What students will learn

Through the use of selection, pupils will understand how the data collected by sensors can be used in the program to trigger events. They will use the light level as a condition and identify what will happen when the light level is above and below are a certain level.

Pupils will also apply their understanding of repetition when considering if they require the sensor to check environmental conditions once or if the conditions should be constantly checked so that the required actions can be carried out whenever the condition is met.

Next steps projects

For teachers feeling confident using micro:bit, these projects are a great way to teach selection and sensors to students.

Saving sea turtles

This project presents pupils with a real-life application of the micro:bit. Pupils will use the micro:bit to aid the protection of newly hatched turtles by replacing artificial lights in their environments while still making them visible to humans.

What students will learn

The program pupils will construct uses the micro:bit’s light sensor to monitor light levels. The data collected is used as a condition in a selection statement so that actions are carried out when the condition is met.

Pupils will make decisions on how they can best use the LEDs to meet the needs of the turtles and make use of their understanding of abstraction. They will also be able to explore the effect on the program of varying the value in the conditional statement so they ensure that the actions are carried out in the correct environmental conditions.

Sensory toy

The sensory toy project introduces pupils to the micro:bit’s accelerometer sensor.

What students will learn

They will learn how it senses the direction of movement, rotation and speed, and use this to construct a program that uses the accelerometer as a trigger to start various outputs.

In this project, pupils will also consider the needs of the user as they will need to select and design images and sounds that will appeal to learners who require additional sensory stimulation. Pupils will understand that selection is not appropriate for this program as the outputs should only be activated by the user and that environmental conditions do not need to be constantly monitored.

Furthermore, this project provides pupils with the opportunity to experiment with the range of inputs created by the accelerometer as a way of adding additional outputs to their program. This project can be taken further by asking pupils to use the micro:bit to create a prototype of their sensor toy.

Aiming further projects

If you are confident using micro:bit in the classroom, these projects are suitable for teaching selection and sensors to students with some micro:bit experience.


The metronome project allows children to explore how inputs can be used to modify an output.

What students will learn

Pupils will program the micro:bit to play a note followed by a pause at specific tempo through the use of a forever loop. Pupils then use the A and B buttons to control the tempo of the music with one button increasing and the other decreasing the tempo.

This program will start pupils to think about how values stored in the micro:bit can be recalled, displayed and used in a program laying the foundations for the projects in the next pathway, It’s all variable. It also offers the opportunity to develop unplugged activities to support learning by asking pupils to use instruments to act out the program and the impact of each input.

Simple door alarm

In this project, pupils will construct a program that responds to two inputs: the micro:bit’s button being pressed and a change in the environment as sensed by the micro:bit’s compass sensor (known as a magnetometer).

What students will learn

The compass sensor measures the Earth’s magnetic field but can also be used to measure the strength of a magnet’s magnet field. Changes in this magnetic field, as the magnet moves further away from the micro:bit, can be used to trigger an output. This program responds to two inputs both leading to an ouput. Pupils will need to decide whether selection needs to be used so that the conditions are constantly monitored and in doing so show their depth of understanding of this concept.

Pupils will need to test and refine their program to ensure that the alarm has the required degree of sensitivity. To do this they will need to modify the value used in their selection statement. Pupils will also need to plan how they will attach the micro:bit and magnet to the door so it operates properly and is discrete.

Finally, pupils will think about the need to reset the alarm after it has been triggered by using a button input to initialise the program. In planning and constructing this program pupils will be required to apply several computer science concepts and computational thinking approaches which makes it suitable for assessing their knowledge, skills and understanding.

You may also like