Kōkiri Learn

Week 3 of 5

Code the decision and build the sensor

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

Session 1 · DESIGN: Sketch

If this, then that

  1. 10 minFlowchart your decision: 'if light level is below 40 then turn on the LEDs, else turn them off'.
  2. 25 minCode it in MakeCode: read the sensor inside a forever loop, and use if/else to control the output.
  3. 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

  1. 5 minSafety check: batteries only, no coin cells on desks, disconnect if warm.
  2. 35 minBuild your context sensor: clothes-peg trap switch, nail soil probe, or light/motion trigger. Connect it with crocodile clips.
  3. 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

Useful this week