Components · 3 min read

What Is a Potentiometer? Analog Reading and Control with Arduino

What is a potentiometer, how does it work and how do you connect it to Arduino? Linear vs logarithmic pots, the B10K code, reading with analogRead and an LED brightness example.

A potentiometer is an adjustable resistor whose resistance changes as you turn its shaft. A radio's volume knob, a lamp dimmer and the sticks of a game controller are all potentiometers. In Arduino projects it's the easiest way to get a value from the user: you turn the knob and the Arduino reads a number between 0 and 1023.

Potentiometer
Rotary potentiometer: the two outer legs are the ends of the fixed resistor, the middle leg is the moving wiper.

How does a potentiometer work?

Inside there's an arc-shaped resistive track and a wiper that slides along it. The resistance between the two outer legs is fixed (for example 10 kΩ). The middle leg is connected to the wiper; as you turn the shaft, the wiper moves along the track and the resistance to each outer leg changes. Put 5 V and GND on the outer legs and you get a voltage between 0 and 5 V on the middle leg. In other words, a potentiometer is an adjustable voltage divider.

Types of potentiometers

TypeLooks likeUsed for
Rotary potShaft, 3 legsVolume, brightness, speed control
Trimpot (trimmer)Small, adjusted with a screwdriverValues set once and left (like LCD contrast)
Slide potSlides along a straight trackMixers and control panels
JoystickTwo pots in oneTwo-axis control (X and Y)
A B10K or B103 marking means a 10 kΩ linear pot: the value changes in proportion to the knob. The letter A marks a logarithmic (audio) pot. For measurement and control with Arduino, choose a linear (B) pot.

Connecting a potentiometer to Arduino

  1. Connect one outer leg to 5V and the other to GND (swapping them just reverses the direction).
  2. Connect the middle leg to an analog input, for example A0.
  3. Connect an LED with a 220 Ω resistor to PWM-capable pin 9.
  4. Upload the code below and open the serial monitor; turning the knob changes the value and the LED brightness.
C++ (Arduino IDE)
1const int POT_PIN = A0;   // potansiyometre orta bacak / pot wiper
2const int LED_PIN = 9;    // PWM pini / PWM pin
3
4void setup() {
5  pinMode(LED_PIN, OUTPUT); // LED çıkış / LED output
6  Serial.begin(9600);       // seri monitör / serial monitor
7}
8
9void loop() {
10  int raw = analogRead(POT_PIN);              // 0–1023 oku / read 0–1023
11  int brightness = map(raw, 0, 1023, 0, 255); // PWM'e çevir / scale to PWM
12  analogWrite(LED_PIN, brightness);           // parlaklık / brightness
13  Serial.println(raw);                        // değeri yaz / print value
14  delay(20);
15}

The map() function converts a value from one range to another, like turning a 0–1023 reading into a 0–255 PWM value or a 0–180 servo angle. To see the voltage divider idea in numbers, use the voltage divider calculator.

Analog reading range by board

BoardResolutionRangeFunction
Arduino Uno / Nano10 bit0–1023analogRead()
ESP3212 bit0–4095analogRead()
Raspberry Pi Pico12 bit (scaled to 16 bit)0–65535ADC.read_u16()
The ESP32 and Pico run on 3.3 V: connect the pot's outer leg to 3.3 V, not 5 V. On the ESP32, only ADC1 pins (GPIO 32–39) read reliably while Wi-Fi is on.

Common mistakes

  • Connecting the middle leg directly to 5V or GND: at the end of its travel this makes a short circuit and can burn the pot. Power always goes to the outer legs.
  • Jittery values: readings can wobble by a few units. Average several readings or ignore small changes.
  • Using a logarithmic pot: with an A-type pot the value changes slowly at the start and fast at the end; use a B type for linear control.
  • Connecting it to a digital pin: a potentiometer gives an analog value, so it must go to an analog input like A0–A5.

You'll find how to set a servo angle with a potentiometer in What Is a Servo Motor?, and the basics of resistance in What Is a Resistor?.

Frequently asked questions

What value potentiometer should I buy for Arduino?

A 10 kΩ linear (B10K) pot is the most common choice. Values from 1 kΩ to 100 kΩ also work; very low values draw more current and very high ones can read noisily.

How do I tell the legs of a potentiometer apart?

Holding it with the shaft facing you, the middle leg is the wiper. The order of the outer legs only decides which way you turn for the value to rise.

Why doesn't the reading reach exactly 0 or 1023?

Contact resistance at the ends and manufacturing tolerance can shift the extreme values by a few units. Leaving a 5–10 unit margin in your code solves it.

Are a joystick and a potentiometer the same thing?

A joystick contains two potentiometers at right angles and usually a button. Each axis is read on its own analog input.

See all projects
Servo Motor Operation with Potentiometer
AR-36Beginner
Premium

Servo Motor Operation with Potentiometer

As you turn the potentiometer knob, the servo motor's arm turns right along with it: one end of the knob means zero degrees, the other end means half a turn.

4.6(37)
54
ESP32 LED Brightness Control with a Potentiometer (Analog → PWM)
ES-13Intermediate
Premium

ESP32 LED Brightness Control with a Potentiometer (Analog → PWM)

In this project, we control the brightness of an LED analogically using a potentiometer. The ESP32's ADC pin reads the 0-3.3V voltage from the potentiometer, and this value is then converted into a PWM (Pulse Width Modulation) signal and sent to the LED. As a result, as you turn the potentiometer, the LED gradually brightens and dims. With Arduino Core 3.0+, analogWrite() can be used directly; on the ESP32-S2/S3, the ADC resolution is fixed at 12-bit.

4.4(20)
32
LED Chaser with Adjustable Speed
AR-7Intermediate

LED Chaser with Adjustable Speed

Six LEDs light up one after another, so the light seems to run from one end to the other.

4.6(74)
154
Knight Rider LED Effect with Adjustable Speed
AR-8Intermediate

Knight Rider LED Effect with Adjustable Speed

A light runs from one end of six LEDs to the other, turns around and runs back again.

4.5(61)
131
Led Control with Joystick
AR-59Intermediate
Premium

Led Control with Joystick

Push the little stick on the joystick all the way in any direction and the LED for that direction lights up: there are four different colours for right, left, up and down.

4.8(51)
68
ESP32 Color Mixer Light (3 Potentiometers + RGB LED + OLED)
ES-36Advanced
Premium

ESP32 Color Mixer Light (3 Potentiometers + RGB LED + OLED)

A smart color-mixer lamp: turn 3 potentiometers on the ESP32 and mix any color you like! As you turn the red, green and blue potentiometers, the common-cathode RGB LED changes color instantly. The SSD1306 OLED display shows each channel's 0-255 value, fill bars and the HEX web color code (like #FF8040) live.

4.7(6)
10
Digital Voltmeter with LCD Display
AR-56Intermediate
Premium

Digital Voltmeter with LCD Display

Find out how much voltage a battery or power adapter gives with a meter you built yourself.

4.5(27)
36