First Lessons With Make Code and The Micro Bit 5 Plan
First Lessons With Make Code and The Micro Bit 5 Plan
Lesson Plan
Lesson 5: Nightlight
Ages: 7 – 11
Programming language: MakeCode blocks
Topics: Selection/conditionals (Programming),
Input/output, Sensors (Computer systems)
Outcomes: Students develop their use of the
micro:bit’s sensors by using logic to make a
simple control system, a nightlight that switches
on automatically when it gets dark.
Learning objectives
I can code a micro:bit to make a light that switches on when it gets dark using
sensors and logic.
I can explain that sensors are inputs that sense things in the real world, such as
movement and light.
I can explain that logic is how computers make decisions in code based on
whether things are true or false.
Differentiation ideas
If this is one of your first coding lessons with the micro:bit, it may be hard to know
which students will need more support. You can use the extension ideas in the
teaching section below for students who complete the task more quickly than
others.
Glossary
output: data sent from a computer such as words shown on the display
I can explain that sensors are inputs that sense things in the real world, such as
movement and light.
I can explain that logic is how computers make decisions in code based on
whether things are true or false.
Explain that Sensors are inputs that measure things outside a computer, like light, or
movement.
Logic is a key idea in computing. It helps machines to make decisions, like turning a
light on if it’s dark.
Students recreate the code, testing it in the simulator. They can either:
Copy the code from slide 6.
Follow printed code blocks handouts.
Individually follow a step-by-step online tutorial:
https://mbit.io/tutorial-night-light - you can share the link from slide 10.
If you are using micro:bit classroom, start a new session and ask your students to
join your lesson. You can also open a session with completed code to edit and
share with students: https://mbit.io/lessons-nightlight-classroom
Questions:
Does it work as you expect?
Change the number 100 to a smaller number if the LEDs switch on too easily.
Change the number 100 to a larger number if it’s hard to make them switch
on.
Transfer the code to the micro:bit and test again.
Ask:
What are sensors? How did you use them? (The LEDs work as an
input, sensing light levels).
What is logic? How did we use it today? (We used logic to make a control
system: if the light level is low, then we turn the lights on, else we turn them off.)
How did you test or improve your code? (Depending on the lighting conditions in
your classroom, students may have had to use larger numbers to make the lights
more sensitive – turn on when it’s brighter – or use smaller numbers to make
them turn on only when it’s very dark.)
When assessing students’ work you may find it helpful to ask these questions:
How well did the student follow instructions to code and test an
automatic nightlight?
Can they explain what sensors are and that the light sensor is used to
make the nightlight work?
What is their understanding of how logic is used to make the light turn
on or off depending on the light level reading from the light sensor?
Here are some guiding criteria you might want to include when assessing your
students’ work:
The student may know a light sensor is used but can’t link the light
sensor to other sensors like the accelerometer or explain what
sensors are in general terms (inputs that sense things in the real
world, such as movement, temperature, and light levels).
The student may be able to use but cannot describe how the ‘if…
then… else’ blocks work using natural language.
The student knows a light sensor is used and can link the light sensor
to other sensors like the accelerometer and can explain what sensors
are in general terms (inputs that sense things in the real world, such
as movement, temperature, and light levels).
The student can describe how the ‘if… then… else’ blocks work using
natural language.
The student knows a light sensor is used and can link the light sensor
to other sensors like the accelerometer and can explain what sensors
are in general terms (inputs that sense things in the real world, such
as movement, temperature, and light levels), and give other examples
of sensors being used in control systems, for example a thermostat in
a heating system.
The student can describe how the ‘if… then… else’ blocks work using
natural language and describe them using the terms ‘selection’ or
‘conditionals’. They may also explain that logic works on the basis of
certain statements being true or false. The student may also explain
that a ‘forever’ or infinite loop is needed so the micro:bit can constantly
keep checking the light level and react accordingly.