Potentiometer
A 10k knob you can turn. Ends to the rails, wiper to an ADC.
- 3 pins
- 2 settings
- In 57 projects
- In 31 lessons
The Potentiometer in brief
What it is, and every setting the properties panel gives it.
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.
- Family
- Inputs
- Pins
- 3
- 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).
A circuit built around it, running and explained: the Potentiometer simulator.
3 pins
Named as the editor names them, so a wire lands where you expect 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.
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);
}What is true about the Potentiometer, here
In its help article’s own words: what the simulation gets right, and where it stops.
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
57 built-in projects use it. Each opens in the editor, already wired.
Where it turns up in a lesson
31 lessons place it in their own circuits.
Learn articles
31 lessons
- Arduino Stepper Motor: 28BYJ-48 and ULN2003
- Arduino Potentiometer Wiring and Code: Dim an LED
- 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
- Arduino "exit status 1": Find the Real Error
- ESP32 DevKit V1 Pinout: Every Pin and Which to Avoid
- Arduino Nano Pinout: PWM, I2C, SPI, A6 and A7
- Arduino Uno Pinout: ATmega328P Pins, PWM, I2C, SPI
- XIAO ESP32-C3 Pinout: D Pins to GPIO, ADC, Boot Pins
- Arduino "Low Memory Available" and "Sketch Too Big"
- Arduino map() Function: Scale Any Reading
- ESP32 PWM: ledcAttach, ledcWrite and Frequency
- Arduino Moving Average: Smooth analogRead Values
- Arduino "expected primary-expression": Fixes
- How Many LEDs Can One Arduino Pin Drive?
- DIY Rhythm Game Controller: Guitar and Dance Pad
- DIY Load Cell Pedals and Flight Stick on a Pro Micro
- DIY Stream Deck and Camera Slider With Arduino
- Arduino Eurorack CV Quantizer With a PWM DAC
- Arduino NeoPixel (WS2812B): Wiring and Code
- Arduino CD74HC4067 Multiplexer: 16 Analog Inputs
- Arduino Self-Balancing Robot: MPU6050 and PID Code
- Raspberry Pi Pico MicroPython in Your Browser
- "Function-Definition Is Not Allowed Here" Fix
- Arduino "invalid types for array subscript": Fix
- ATtiny85 Pinout: PB0 to PB5, ADC, PWM, I2C and ISP
- Microcontroller Lab Viva Questions, With Answers
- Simulate an ESP32 and an Arduino Uno Together
- ESP32 Projects for Beginners You Can Run Right Now
The boards it is shown on
Each of these 11 boards has a built-in project with the Potentiometer in it.
The Potentiometer on each board
The pins, the voltage and the code change from board to board. Each page has that board’s wiring and a circuit you can run.
Arduino libraries for the Potentiometer
Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.
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.