Wiring a standard 10kΩ linear potentiometer (pot) to an Arduino Uno R3 requires exactly three connections: the left outer pin to 5V (VCC), the right outer pin to GND, and the middle wiper pin to an analog input (A0). This configuration creates a variable voltage divider that outputs 0V to 5V, which the Arduino’s 10-bit Analog-to-Digital Converter (ADC) reads as integer values from 0 to 1023. If your readings are erratic or pegged at the extremes, the issue is almost always a wiper misidentification or a missing hardware low-pass filter.
Parts List & Pin Mapping Specification
Before stripping wires, verify your components. Using the wrong potentiometer taper or an incompatible logic-level board will result in non-linear data or damaged silicon.
| Component | Exact Variant / Specification | Notes & Assumptions |
|---|---|---|
| Microcontroller | Arduino Uno R3 (ATmega328P) | 5V logic, 10-bit SAR ADC. Code targets this exact variant. |
| Potentiometer | 10kΩ Linear Taper (B10K) | Must be linear (B). Audio taper (A) will skew mid-range readings. |
| Filter Capacitor | 0.1µF Ceramic (50V) | Optional but highly recommended for hardware noise suppression. |
| Wiring | 22 AWG Solid Core Jumper Wires | Stranded wire causes breadboard contact bounce and erratic ADC reads. |
Pin Mapping Table
| Potentiometer Pin | Function | Arduino Uno R3 Connection |
|---|---|---|
| Pin 1 (Outer Left) | VCC / High Reference | 5V |
| Pin 2 (Middle) | Wiper / Variable Output | A0 (Analog Input) |
| Pin 3 (Outer Right) | GND / Low Reference | GND |
Step-by-Step Wiring Procedure
- Identify the Wiper: Set your multimeter to resistance (Ω) mode. Place probes on the middle pin and one outer pin. Rotate the shaft. If the resistance changes, you have the wiper and one outer pin. The remaining pin is the other outer reference.
- Seat the Component: Press the potentiometer firmly into the breadboard. Ensure all three pins are in separate, unconnected rows.
- Wire Power and Ground: Connect the left outer pin to the Arduino 5V rail. Connect the right outer pin to the Arduino GND rail.
- Wire the Signal: Connect the middle wiper pin directly to Arduino Analog Pin A0.
- Add Hardware Filtering (Crucial for Stability): Insert a 0.1µF ceramic capacitor between the wiper row (A0) and the GND rail. This forms an RC low-pass filter that physically blocks high-frequency electromagnetic interference (EMI) before it reaches the ADC.
- Verify Before Powering: Use your multimeter in DC Voltage mode. Probe the wiper and GND. Rotate the knob. You should see a smooth transition from 0.00V to 5.00V. If it jumps or stays at 0V/5V, re-check your wiper identification.
Compilable Code with ADC Smoothing & Error Handling
Raw analogRead() calls on breadboard-mounted pots are notoriously noisy due to carbon track inconsistencies and breadboard contact micro-vibrations. The code below targets the Arduino Uno R3 and implements an Exponential Moving Average (EMA) filter alongside a hardware-fault detection routine to catch disconnected wipers or shorted pins.
#include <Arduino.h>
// --- PIN DEFINITIONS ---
#define POT_PIN A0 // Analog pin connected to the wiper
#define LED_PIN 13 // Built-in LED for fault indication
// --- ADC CONFIGURATION ---
#define ADC_MAX 1023 // 10-bit resolution for ATmega328P
#define ADC_MIN 0
#define EMA_ALPHA 0.15f // Smoothing factor (0.0 to 1.0). Lower = smoother but more lag.
// --- FAULT THRESHOLDS ---
#define DELTA_FAULT 300 // Max physical change in 2ms. Higher indicates a floating pin/noise.
#define STUCK_FAULT 50 // If reading stays exactly at 0 or 1023 for this many loops, flag fault.
// Enum for hardware state tracking
enum PotStatus {
STATUS_OK,
STATUS_DISCONNECTED, // Pegged at 1023 (internal pullup effect) or 0
STATUS_NOISY // Physically impossible delta change
};
float smoothedValue = 0.0;
int previousRaw = 0;
int stuckCounter = 0;
PotStatus currentStatus = STATUS_OK;
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
// Prime the EMA filter with an initial reading to prevent startup lag
smoothedValue = analogRead(POT_PIN);
previousRaw = (int)smoothedValue;
Serial.println("Arduino Pot Wiring Initialized. EMA Filter Active.");
}
void loop() {
int rawValue = analogRead(POT_PIN);
// --- ERROR HANDLING & FAULT DETECTION ---
int delta = abs(rawValue - previousRaw);
if (delta > DELTA_FAULT) {
currentStatus = STATUS_NOISY;
Serial.println("[ERROR] Hardware Fault: Excessive ADC delta detected. Check breadboard contacts.");
}
else if (rawValue >= ADC_MAX - 1 || rawValue <= ADC_MIN + 1) {
stuckCounter++;
if (stuckCounter > STUCK_FAULT) {
currentStatus = STATUS_DISCONNECTED;
Serial.println("[ERROR] Hardware Fault: Wiper appears disconnected or shorted to rail.");
}
} else {
stuckCounter = 0;
currentStatus = STATUS_OK;
}
// --- SIGNAL PROCESSING ---
// Apply Exponential Moving Average (EMA)
smoothedValue = (EMA_ALPHA * rawValue) + ((1.0 - EMA_ALPHA) * smoothedValue);
previousRaw = rawValue;
// Map to a usable 0-100 percentage scale with strict bounds checking
int percentage = constrain(map((int)smoothedValue, ADC_MIN, ADC_MAX, 0, 100), 0, 100);
// --- OUTPUT & UI FEEDBACK ---
if (currentStatus == STATUS_OK) {
digitalWrite(LED_PIN, LOW);
Serial.print("Raw: "); Serial.print(rawValue);
Serial.print(" | Smoothed: "); Serial.print(smoothedValue, 1);
Serial.print(" | Output: "); Serial.print(percentage);
Serial.println("%");
} else {
// Blink LED to indicate hardware fault to the user without needing Serial Monitor
digitalWrite(LED_PIN, (millis() / 100) % 2);
}
delay(20); // 50Hz sample rate
}
Debugging: The First Three Things to Check When It Fails
When your serial monitor outputs garbage data, the ATmega328P's Successive Approximation Register (SAR) ADC is rarely the culprit. The failure is almost always in the physical circuit. Follow this ranked diagnostic path:
1. The Wiper vs. Outer Pin Mix-Up (Symptom: Pegged at 0 or 1023)
If your serial monitor reads a constant 1023 or 0 regardless of knob position, you have wired the wiper to one of the outer reference pins, and an outer pin to A0. The ADC is reading the fixed 5V or GND rail. Fix: Swap the A0 wire with one of the outer power/ground wires and test again. Alternatively, use a multimeter to verify continuity while rotating the shaft.
2. Floating Ground or VCC Bounce (Symptom: Erratic Jumping)
If the values jump wildly (e.g., 400, 12, 890, 55) when you aren't touching the knob, your power or ground connection is bouncing. Breadboard contacts degrade over time, and the high impedance of the ADC (approx. 100MΩ) makes it incredibly sensitive to micro-disconnects. Fix: Move the pot to a fresh section of the breadboard, or solder the connections. Ensure you are using the 0.1µF capacitor mentioned in the wiring steps to bridge transient gaps.
3. Incorrect ADC Reference Voltage (Symptom: Max reading is ~700 instead of 1023)
If turning the pot to the maximum 5V position only yields a reading around 700, your Arduino's AREF (Analog Reference) pin might be shorted to a lower voltage, or you are accidentally powering the pot from the 3.3V pin while expecting a 5V scale. Fix: Verify the voltage at the pot's outer pins with a multimeter. Ensure the AREF pin on the Arduino is unconnected (floating) so the internal 5V reference is used by default (Arduino analogReference docs).
Extending and Simplifying the Build
How to Simplify the Code
If you are building a simple LED dimmer and don't need fault detection, strip the code down to the map() and constrain() functions. Never use map() without constrain(); if analog noise pushes the raw value to 1025, map() will output a value outside your target range, potentially causing integer overflow in downstream motor or servo logic.
How to Extend with Hardware RC Filtering
Software smoothing (like the EMA in the code above) introduces latency. For real-time audio or high-speed motor control, you must filter the noise in hardware. By adding a capacitor between the wiper and GND, you create a first-order RC low-pass filter.
Worked Numeric Example:
Using our 10kΩ potentiometer and a 0.1µF (100nF) ceramic capacitor, we can calculate the cutoff frequency ($f_c$) using the standard formula $f_c = \frac{1}{2 \pi R C}$ (Electronics Tutorials: Potentiometers).
- $R = 10,000 \Omega$ (Worst case, wiper at maximum resistance)
- $C = 0.0000001 F$
- $f_c = \frac{1}{2 \times 3.14159 \times 10000 \times 0.0000001} \approx 159 Hz$
This means any electrical noise above 159Hz (like 60Hz mains hum harmonics or switching power supply ripple) is physically shunted to ground before the Arduino's ADC sample-and-hold circuit even sees it (Arduino Analog Pins Guide).
Frequently Asked Questions
Does the resistance value (10k vs 50k vs 100k) matter for Arduino pot wiring?
Yes, 10kΩ is the optimal standard. The ATmega328P ADC is optimized for an analog source impedance of 10kΩ or less. If you use a 100kΩ potentiometer, the internal sample-and-hold capacitor inside the microcontroller won't have enough time to charge fully during the ADC conversion cycles, resulting in consistently lower-than-actual readings and increased susceptibility to noise. If you must use a high-resistance pot, add a 10kΩ resistor in parallel or buffer the signal with an op-amp voltage follower.
Why is my Arduino pot wiring reading erratic values even when not touching it?
Potentiometers use a physical metal wiper sliding across a carbon or cermet track. Micro-vibrations from your desk, acoustic noise, or even thermal expansion can cause the contact resistance to fluctuate by a few ohms. Because the Arduino's 10-bit ADC divides 5V into 1024 steps (approx 4.8mV per step), a tiny 10mV fluctuation on the carbon track registers as a 2-count jump in your serial monitor. This is normal physical behavior and is exactly why the EMA software filter and 0.1µF hardware capacitor are required.
Can I wire multiple potentiometers to the same Arduino analog pins?
You cannot wire them to the exact same physical pin simultaneously without using a multiplexer (like the CD4051). However, the Arduino Uno R3 has six analog pins (A0 through A5). You can wire up to six potentiometers directly. Keep in mind that the ADC shares a single internal conversion circuit; switching between pins (e.g., reading A0 then A1) requires a brief settling time (usually 1-2 dummy reads) to allow the internal multiplexer and sample-and-hold capacitor to stabilize to the new voltage.
What happens if I wire the 5V and GND backward on the potentiometer?
For the potentiometer itself, nothing bad happens. A resistor network does not care about current direction; it will simply output an inverted voltage curve (turning the knob clockwise will decrease the ADC value instead of increasing it). You can fix this in software by subtracting the raw reading from 1023. However, if you are using a 3.3V microcontroller and accidentally wire the pot to 5V and GND, the 5V wiper output will exceed the GPIO's absolute maximum ratings and destroy the pin.






