
Session 1 · DESIGN: Sketch
If this, then that
- 10 minFlowchart your decision: 'if light level is below 40 then turn on the LEDs, else turn them off'.
- 25 minCode it in MakeCode: read the sensor inside a forever loop, and use if/else to control the output.
- 15 minTest in the simulator, then on the real board. Print the sensor reading so you can see the numbers.
Session 2 · DESIGN: Improve
Build the sensor
- 5 minSafety check: batteries only, no coin cells on desks, disconnect if warm.
- 35 minBuild your context sensor: clothes-peg trap switch, nail soil probe, or light/motion trigger. Connect it with crocodile clips.
- 10 minRecord sensor readings in two states (wet and dry, open and closed, light and dark) to choose your trigger level.
Getting started
Use the starter program that shows the sensor reading as a number, then add one if block.
Stretch
Use radio to send an alert from one micro:bit to another across the room.
Checkpoint
Code that reads your sensor and changes an output, with a chosen trigger level backed by readings.
Activities for this week
- Night light with a light sensor: How can a microcontroller decide when it is dark enough to turn on a light?
- Nail soil moisture sensor: Can two nails and a micro:bit tell you when a plant is thirsty?
- Clothes-peg trap switch and radio alert: How can a trap tell a volunteer it has been triggered?
Useful this week
- micro:bit features ↗ Every input and output on the board, in one place.
- Electricity and sensors ↗ How sensors turn changes in the world into electrical signals.
- Microsoft MakeCode for micro:bit ↗ Block coding with a simulator, so you can test before you download.
- Soil moisture project ↗ Step-by-step guide to a nail soil sensor.