Potentiometer
A 10k knob you can turn. Ends to the rails, wiper to an ADC.
- 3 pins
- 2 properties
Every one of its 3 pins
What it does
A potentiometer is a resistive track with a wiper that slides along it. With the two ends on the supply and ground, the wiper sits at a voltage in proportion to where it is, which makes it a voltage divider you can set by hand; with one end tied to the wiper, it becomes a variable resistor. Mokxi models the track itself rather than either use, so both wirings work and the wiper has the source resistance a real one has, up to a quarter of the track value at the center, which bends the reading under a heavy load. On a 5 volt Arduino the wiper reads 0 to 1023 on an analog pin; on a 3.3 volt board it swings 0 to 3.3 volts with nothing special to change. The value and the taper, linear or log, are properties. The track is ideal, with no wiper noise, so a reading that would wobble on a desk is steady here.
How to use a potentiometer with an Arduino
One end to 5 V, the other to GND, the middle leg (the wiper) to an analog pin. analogRead() then gives 0 to 1023 across the travel. To use it as a brightness, scale it to 0 to 255 for analogWrite() on a PWM pin, by dividing by four or shifting right by two.
A real pot’s reading wobbles by a count or two, so average a few readings or smooth them before driving anything the eye or ear will notice.
On an ESP32, put the ends on 3.3 V and GND; its ADC reads 0 to 4095, and the ESP32 knob example shows how its attenuation sets the top of the scale.
void loop() {
int reading = analogRead(A0); // 0..1023
analogWrite(9, reading >> 2); // 0..255
delay(5);
}The 2 properties you can set
What is true about the Potentiometer, here
What is modeled
The wiper's source impedance is the two halves of the track in parallel (zero at
either end of travel, 2.5 k at center for a 10 k pot), which is real, and is why a
pot with a load on its wiper does not read as a perfectly clean divider. Whatever is
on the ends is what the wiper swings between, so a pot on a 3.3 V board reads 0 to
3.3 V with no special case anywhere. taper bends the position into the fraction
along the track without changing anything else about the model.
Not modeled
No mechanical stops beyond the travel limits, and no wear on the track over time.
The track is ideal: no wiper contact resistance, no end resistance where the track
meets its terminals, no tolerance on the total value (a real pot is ±20%), no
temperature coefficient, no noise, and none of the scratchiness a worn pot has as the
wiper crosses it. The position is a clean 0 to 1023 with no jitter, so an ADC reading it
never wobbles the way a real one does and a sketch that would need smoothing on the
bench does not need it here. taper bends the position into the fraction along the
track; the log law is an approximation of a real audio taper rather than a curve off any
datasheet.
From Potentiometer, in full.
See the Potentiometer in a project
Shown here on: Arduino Uno R3, ATtiny85, Arduino Nano, ESP32 DevKit V1, Arduino Uno R4 Minima, Seeed XIAO ESP32-C3
Where it turns up in a lesson
In a learn article
- Arduino Stepper Motor: 28BYJ-48 and ULN2003
- Arduino Potentiometer: analogRead and a Dimmer
- Analog vs Digital Pins, and ADC Resolution
- An Op-Amp as a Comparator, With Hysteresis
- ESP32 analogRead: 12 Bits, Attenuation and ADC2
- How to Debug Arduino Code: Prints to Breakpoints
- How Many LEDs Can One Arduino Pin Drive?
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Potentiometer
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.