Part

Potentiometer

A 10k knob you can turn. Ends to the rails, wiper to an ADC.

or see every part
  • 3 pins
  • 2 properties
Drawn live by the editor's own code, at the size you see it.
Reference

Every one of its 3 pins

Pin
What it does
1
One end of the track.
2
The wiper.
3
The other end of the track.
This part

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 it

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.

Part pin
Board pin
Pin 1 (one end)
5 V
Pin 2 (the wiper)
A0
Pin 3 (the other end)
GND

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.

Arduino Uno: dimmerlive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
A knob dimming an LED on pin 9
void loop() {
  int reading = analogRead(A0);   // 0..1023
  analogWrite(9, reading >> 2);   // 0..255
  delay(5);
}
Reference

The 2 properties you can set

Property
Default
What it means
value
10000
the track resistance in ohms, 10 000 (10 k) by default.
taper
linear (or log)
linear (every pot in an Arduino kit) or log (a volume control).
How it is modeled

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.

Projects

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

Wire up the Potentiometer

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.