Skip to content

Nightlight

Lesson 5 of 6

MakeCode

7-11 yrs

Make an automatic nightlight and discover how logic, conditionals and inputs and outputs combine to make a simple control system.

Key learning:

  • Understand how inputs, outputs, and computer code work together to make control systems.
  • Understand how logic (conditional ‘if… then… else’ instructions) is used to make different outputs happen depending on changes in data from a sensor.
  • Use ‘forever’ infinite loops to keep control systems responding to changes in the environment.
  • Practise testing and improving a project to make the nightlight work better in specific local lighting conditions.

Computer systems:

Input/output

Sensors

Programming:

Selection

Lesson plan preview

Slides preview

Student handouts

Completed lesson code

This provides an example of the code created during this lesson.

You may also be interested in

Unit of work

Nature art

This unit of four lessons is suitable for students aged 7-8 years. They create nature representations, firstly using art materials and are introduced to computational thinking and programming the LEDs on the BBC micro:bit. 

Make it: code it

Name badge

Turn your micro:bit into an animated name badge