Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

Potentiometer with Arduino Uno — analogRead, volts and PWM dimming

Wire a 10 kΩ potentiometer to an Arduino Uno R3 on A0, read 0–1023, convert to volts and percent, and use it to set PWM on D9.

Arduino C++Verified — core avr 1.8.8, 3 Nov 2026Compile-only

Community draft — report a mistake

A potentiometer is a knob that gives out any voltage between its two ends. It is the first analog input most people use: it sets a brightness, a motor speed, a servo angle or a threshold.

On the Uno, put the outer legs on GND and 5V and the middle leg (the wiper) on A0. The Uno’s 10-bit ADC turns 0–5 V into a number from 0 to 1023.

The sketch prints the raw reading, the voltage and a percentage. It also passes the value to PWM on D9, so an LED there dims as you turn the knob. That is the same analogRead → map → analogWrite pattern you will use for fans and motors later.

Wiring

Arduino Uno R3Only the pins used are shown · 5 V logicRotary potentiometer (10 kΩ, B10K)5VGNDA0Pin 1WiperPin 3
Every connection
Arduino Uno R3Rotary potentiometer (10 kΩ, B10K)WireNotes
GNDPin 1black
A0WiperyellowThe middle leg.
5VPin 3redSwap Pin 1 and Pin 3 if the value should rise the other way.

Passive — across the board’s 3.3 V or 5 V part, 5 V board. Connect the outer legs to the same voltage your ADC uses: 3.3 V and GND on ESP32 and Pico, 5 V and GND on Uno. The wiper can then never exceed the pin limit.

Board quirks

  • Use a 10 kΩ pot. The Uno’s ADC wants a source of 10 kΩ or less; a 100 kΩ or 1 MΩ pot gives readings that wander and lag.
  • The Uno’s ADC is 10-bit: 0–1023 for 0–5 V, about 4.9 mV per step.
  • The voltage shown assumes exactly 5.0 V. On USB the 5V pin is often 4.7–5.1 V, so the volts can be a little off — but the raw value and the percent stay right, because the pot and the ADC use the same supply.
  • analogWrite() only works on the PWM pins (3, 5, 6, 9, 10, 11). The sketch uses D9; add an LED with a 220 Ω resistor from D9 to GND to see it dim.

Code

potentiometer-uno.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// Potentiometer on an Arduino Uno R3: Pin 1 → GND, Wiper → A0, Pin 3 → 5V.
// Prints the raw 10-bit reading, the voltage and a percentage, and sets the
// PWM duty on D9 (connect an LED + 220 Ω resistor there to see it dim).
const uint8_t POT_PIN = A0;
const uint8_t PWM_PIN = 9;

void setup() {
  pinMode(PWM_PIN, OUTPUT);
  Serial.begin(9600);
  Serial.println(F("Turn the knob"));
}

void loop() {
  int raw = analogRead(POT_PIN);    // 0..1023
  float volts = raw * 5.0 / 1023.0; // assumes 5.0 V - USB is often 4.7-5.1 V
  int pct = map(raw, 0, 1023, 0, 100);
  analogWrite(PWM_PIN, raw / 4);    // 0..255
  Serial.print(F("Raw "));
  Serial.print(raw);
  Serial.print(F("  "));
  Serial.print(volts, 2);
  Serial.print(F(" V  "));
  Serial.print(pct);
  Serial.println(F(" %"));
  delay(200);
}

Expected serial output

Serial Monitor · 9600Output
Turn the knob
Raw 0  0.00 V  0 %
Raw 512  2.50 V  50 %
Raw 1023  5.00 V  100 %

Common errors

Value jumps from 0 to 1023 with nothing in between

The wiper is on an outer leg. The middle leg is always the wiper — move A0 there.

Readings flicker by a few counts

Normal ADC noise. Average 4–8 readings, or ignore changes smaller than 3 counts.

The pot gets hot

An outer leg is shorted to the wiper position, or 5V and GND are both on the same side. Unplug and check the three wires.

↑↓ to move · Enter to open