Electronics for Building Things · Lesson 10 · Components in Depth

Potentiometers & Variable Resistors

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.

The one win You can wire a potentiometer correctly and read its position as a number in your sketch — the basis of dials, set-points, and dimmers for your home-automation gadgets.

It's a voltage divider you can turn

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).

+ (3.3V) GND → analog pin middle pin = wiper = variable voltage out
Outer pins to power and ground; the middle (wiper) gives a voltage that swings from 0V to the supply as you turn the knob.
Wiring rule of thumb Outer two pins → power and ground (either orientation; swapping them just reverses the knob's direction). Middle pin → an analog input.

Turning the knob into a number

An analog input pin measures that wiper voltage and your code reads it with analogRead(). The number's range depends on the board:

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.

The same trick reads sensors

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.

Two quick distinctions

Check yourself

Read this next (primary source) SparkFun — Reading a Potentiometer. A complete wire-it-and-read-it walkthrough with code.
I'm your teacher — ask me anything. Want to use a knob as a set-point (say, "turn on the fan above this temperature")? Bring me the idea and we'll map the reading together.

See also: Glossary · Component field guide · Rules of thumb