Students turn a knob on pin 0 and see analog read give 0 to 1023, convert between position, reading and volts, swap in a light sensor in a divider, and set a threshold for a night light.
Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
SlidesDownload Present from the browser, or export to PowerPoint or PDF.
WorksheetDownload Print the student copy; the Teacher edition has the answers.
Students will be able to
I can explain what analog read gives.
I can convert between a reading and volts.
I can choose a threshold so a program decides at the right moment.
Timing
Predict and Try 6 min · Worked example 12 min · Vary 10 min · Tinkercad 8 min · Practise and Make 9 min
Before class
Model: analog read is 0–1023 for 0–3.3 V (the micro:bit's 10-bit reading); the knob and the light sensor give a voltage in proportion to the position or the light. Real light sensors (photoresistors) are far from linear, which Tinkercad will show.
Links: Digital systems › binary (10 bits make 1024 patterns, 0 to 1023).
Running the lesson
Predict: ask those who chose 1.65 what unit analog read gives.
Worked example: draw the three scales one above the other.
Vary, swap them: draw both dividers and ask which end the sensor is on.
Make: compare thresholds. Who picked one close to 205, and what could go wrong?
The hard part (on purpose)
Three scales at once (percent, reading, volts) blur together. Keep a number line on the board with all three marked.
When students get stuck
What you will see
A question to ask
The fix
A student reports volts as the reading.
What is the biggest number analog read can give?
1023, for 3.3 V.
A student's threshold works backwards.
Does darker make the reading bigger or smaller, in this circuit?
Smaller here: lights on below the threshold.
Answers to the checks
halfway: The knob is turned halfway. Analog read pin P0 gives about… About 512: halfway between 0 and 1023. The pin has about 1.65 V on it, but the reading is a number on a 0 to 1023 scale.
Halfway: Turn the knob halfway. What does pin 0 read?
512 (1.65 V): half of the 0 to 1023 scale.
All the way: Turn it all the way up.
1023, for 3.3 V: the top of the scale.
Halfway, in numbers: The knob is a quarter of the way up. What does analog read give? (round to a whole number) 256 0.25 × 1023 = 255.75 ≈ 256.
Number to volts: Pin 0 reads 818. About how many volts is that? (2 decimal places) 2.64 818 ÷ 1023 = 0.8, and 0.8 × 3.3 = 2.64 V.
Find the mistake: Sam is worried about the knob. Click the line where Sam's reasoning first goes wrong. line 3 Line 3: 1023 is the top of analog read's scale, not volts. It stands for 3.3 V, the most a micro:bit pin can have.
Dark: Cover the sensor: make it dark. What happens to the reading?
It falls towards 0. Wired this way (light sensor on the 3V side) less light means less voltage on pin 0.
The 300 mark: Find the light level (%) where the reading passes 300. 30 300 ÷ 1023 ≈ 0.29, so about 29–30% light.
Swap them: Swap the light sensor and the 10 kΩ resistor round. What happens to the reading as it gets darker? It goes up instead of down Which way the divider is wired decides whether brighter means a bigger or a smaller number.
Volts to a reading: 3.3 V on pin 0 reads 1023. What does 0.66 V read? (whole number) 205 0.66 ÷ 3.3 = 0.2, and 0.2 × 1023 ≈ 205.
A threshold: A plant alarm beeps when a soil sensor reads below 400. Which reading beeps? 350 Only 350 is below the threshold.
a night light: Set the threshold so the lights come on when the light drops to 20%, but stay off at 40%. Then test it by making it dark.
A threshold between 205 and 409 does it. Real night lights also leave a gap (hysteresis) so they don't flicker at dusk.
Solutions
One possible solution for each task. Other correct programs are fine.
Vary: a light sensor › Dark
Open task: any program that does what the step asks.
Vary: a light sensor › The 300 mark
Open task: any program that does what the step asks.
Vary: a light sensor › Swap them
Open task: any program that does what the step asks.
a night light
Open task: any program that does what the step asks.
Stretch and support
Stretch: Why 1023? How many bits does the micro:bit use for an analog reading?
Support: A printed number line with 0, 512 and 1023 above 0 V, 1.65 V and 3.3 V.
Exit ticket
Pin 0 reads 256. Roughly how many volts are on it, and what fraction of the way up is the knob?
About a quarter of the way up, so about 0.83 V (256 ÷ 1023 × 3.3).
What each step is for
halfway: Committing to the reading at halfway tests the new move: analog read maps 0–3.3 V onto 0–1023. Each wrong option is a real slip: the volts, a percentage, a digital 1.
Try: turn the knob: Turning the knob settles the prediction and shows both ends of the scale.
Worked example: number and volts: Converting between position, reading and volts models the move; Sam's 'the number is volts' is planted after the method.
Vary: a light sensor: Swapping the knob for a light sensor in a divider shows the same move with a real-world input: light changes the voltage, so the number.
Build it in Tinkercad: Tinkercad's photoresistor and potentiometer, read with analog read and shown on the micro:bit, check the idea in a fuller simulator.
readings: Readings, volts and percentages both ways, and a threshold decision.
a night light: Setting a threshold so the lights switch on at the right darkness reverses the process: from a behaviour to a number.
Where it leads
Next: the Arduino unit (the same circuits on an Uno: analogRead gives 0 to 1023 there too).
Digital systems: How many patterns? (10 bits). Code: micro:bit Foundations sensors (light level 0–255 is a different scale).