Session 1 · 90 min
How does turning a knob become a number?
The potentiometer as a voltage divider; analogRead() gives 0 to 1023 for 0 V to 5 V; a floating analog pin.
In the studio
Hands-on
In Turn a knob, predict the reading at three knob positions, then test. On the bench, with USB unplugged, wire the potentiometer's outer legs to the 5V and GND rails and its middle leg to A0. Print analogRead(A0) and, at three positions, measure the middle leg's breadboard row to the GND rail on DC volts. Then unplug USB, move the A0 wire to an empty row, plug USB back in and watch the reading wander.
Starting code: Analog Read Serial, from File/Examples/01.Basics/AnalogReadSerial: it prints analogRead(A0).
Pins
- A0
- potentiometer middle leg (then a loose wire, for the floating test)
Evidence to collect
A table for three knob positions: measured volts, the printed reading, and the reading × 4.9 mV compared with the meter. A note on the floating reading.
- Predict
- Predict the reading at the knob's two ends and its middle before you turn it.
- Debug
- If the reading sticks at 0 or 1023, unplug USB and check that the middle leg, not an outer leg, goes to A0.
- Reflect
- Why does a pin that is joined to nothing still give a number?
⚠ Adult checks before power-on: USB unplugged while wiring and while moving the A0 wire; only the outer legs go to 5V and GND; the middle leg goes to A0. For the volts readings: red lead in the V/Ω socket, never 10A; probes go on breadboard rows or rails, not at the header pins.
Works towards: Analog readings in code, Noise and timeouts