Electronics for Building Things · Lesson 10 · Components in Depth
A knob your board can read — and the bridge from resistance to a number in code.
A potentiometer ("pot") is the knob on a volume dial — and it's your first real analog input. It builds directly on the voltage divider from Lesson 8, so this lesson ties the component track to writing code that responds to the physical world.
A potentiometer is a resistor with a sliding contact (the wiper). It has three pins: the two outer pins are the ends of the resistor, and the middle pin is the wiper. Turning the knob moves the wiper along the resistor — exactly the adjustable voltage divider from last lesson (SparkFun: Reading a Potentiometer).
An analog input pin measures that wiper voltage and your code reads it with
analogRead(). The number's range depends on the board:
0 (0V) to 1023 (5V).0 (0V) to 4095 (3.3V) — your
home-automation board reads with finer resolution.You then map() that raw number to whatever you need — a brightness 0–255, a temperature
set-point, a delay. The knob position becomes a value your logic acts on.
Swap the pot for a resistive sensor (a photoresistor for light, a thermistor for temperature) plus one fixed resistor, and you've built the divider from Lesson 8. The wiper voltage now changes with the world instead of a knob — and you read it the same way. The potentiometer is how you learn the pattern; the pattern reads half the sensors you'll ever use.
See also: Glossary · Component field guide · Rules of thumb