How to wire a potentiometer to an Arduino Uno R4
To wire a potentiometer to an Arduino Uno R4, connect 1 to 5V, 2 to pin A0 and 3 to GND. Run the pot from 5 V: the wiper then swings from 0 to 5 V, which is exactly the range of the board’s converter. The sketch below uses no library beyond what the board includes. It reads the wiper and prints the raw reading and a percentage.
- 5 V logic
- Library: none
- 3 wires
Potentiometer to Arduino Uno R4 wiring table
Every wire in the circuit above, with the part’s pin names and the board’s own labels. The wire colors are the ones the circuit uses; on a real bench any colors work.
| Potentiometer pin | Arduino Uno R4 pin | Wire color | Why |
|---|---|---|---|
| Pin 1 (one end) | 5V | red | The top of the range: the ADC measures against 5 V. |
| Pin 2 (wiper) | pin A0 | amber | The middle leg: a voltage between the two ends, set by the shaft. |
| Pin 3 (other end) | GND | blue | The bottom of the range. |
Power and logic levels for potentiometer and Arduino Uno R4
Logic level
The Arduino Uno R4’s pins are 5 V logic. A 5 V part can drive them directly; a part whose signal pins are limited to 3.3 V needs a level shifter.
Supply
The potentiometer takes 5 V from 5V. That is the Arduino Uno R4’s 5 V rail, so the part shares the current the board can supply.
This pair
The RA4M1’s converter is fourteen bits, but analogRead() returns ten (0 to 1023) so Uno sketches keep working; analogReadResolution(14) gives 0 to 16383. Any value of pot from 1 k to 100 k works; 10 k is the usual one.
Pins to leave alone
An Uno sketch’s source builds for the R4, but a compiled Uno program will not run on it: different chip. The R4’s pins source less current than an Uno’s, about 8 mA each, so do not drive a relay coil or a motor straight from one.
The working code for the Arduino Uno R4
Library: none, the sketch reads the wiper with analogRead(). This is the sketch the circuit above runs.
const int POT_PIN = A0; // the wiper, pin A0
void setup() {
Serial.begin(9600);
}
void loop() {
int raw = analogRead(POT_PIN); // 0 to 1023
int percent = map(raw, 0, 1023, 0, 100);
Serial.print("Raw: ");
Serial.print(raw);
Serial.print(" Percent: ");
Serial.println(percent);
delay(200);
}
What you should see
Open the serial monitor at 9600 baud and turn the knob: each line shows the raw reading and a percentage that follow it. The RA4M1’s converter is fourteen bits, but analogRead() returns ten (0 to 1023) so Uno sketches keep working; analogReadResolution(14) gives 0 to 16383.
A reading that jumps around or stays at zero means the wiper is not on the analog pin, or the outer legs are not on power and ground.
The serial monitor prints this, recorded from the circuit above with the knob at its middle:
Raw: 511 Percent: 49Common mistakes wiring a potentiometer to an Arduino Uno R4
Expecting 14 bits by default
analogRead() on the R4 returns 0 to 1023 until the sketch calls analogReadResolution(14). Code that assumes 16383 at the top reads a quarter of the scale.
Wiring the wiper to an end
The middle leg is the wiper. With an end leg on the analog pin the reading never moves, or jumps from 0 to the top at one end of the travel.
Trusting the last count
A real pot’s reading wobbles by a count or two. Average a few readings, or ignore changes smaller than 3, before driving something the eye or ear will notice.
Build your own potentiometer project
Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.