If your potentiometer code for Arduino is outputting jittery, stuck, or non-linear values, the issue is almost always hardware, not software. Before rewriting your C++ sketch, you need to verify the physical component. A healthy 10kΩ linear (B-taper) potentiometer should read exactly 10kΩ (±20%) across its outer pins, and sweep smoothly from 0Ω to 10kΩ between the wiper and either outer pin without dropping to an open load (OL) state.

This guide walks you through the exact bench-top measurement techniques to validate your potentiometer, interpret the readings, and translate those physical limits into robust Arduino ADC code.

Meter Setup and Probe Placement for Potentiometer Testing

Accurate resistance measurements require isolating the component and configuring your digital multimeter (DMM) correctly. Measuring a potentiometer while it is still wired into a powered or unpowered breadboard will yield false readings due to parallel current paths through the microcontroller's internal pull-up/pull-down resistors.

Meter Setup Block
  • Dial Position: Resistance (Ω). If your meter has a dedicated continuity mode, use that to check for dead shorts, but switch back to Ω for sweep testing.
  • Lead Jacks: Black lead to COM (Common), Red lead to V/Ω (Voltage/Ohms).
  • Range: Auto-ranging is preferred. If using a manual ranging meter, set it to the 20kΩ or 200kΩ range to capture the full sweep of a standard 10kΩ pot without overloading the display.

Safety Category (CAT Rating) Note: For measuring the 5V or 3.3V DC logic side of an Arduino breadboard, a CAT I rated multimeter is the minimum safety requirement. However, if your debugging process requires you to trace power back to the AC mains side of the Arduino's wall-wart power supply, you must use a CAT II or CAT III rated meter to protect against transient line spikes. Never use a CAT I meter on AC mains voltages.

Probe Placement by Test Point:

  1. Total Resistance (Track Integrity): Place the red probe on Outer Pin 1 and the black probe on Outer Pin 3. The center wiper pin (Pin 2) is ignored for this test.
  2. Wiper Sweep (Variable Output): Place the red probe on Outer Pin 1 and the black probe on the Center Wiper (Pin 2). Slowly rotate the shaft through its full mechanical travel.

Expected Readings: Good vs. Bad Potentiometer Values

Carbon-track potentiometers degrade over time. The wiper can wear away the resistive element, creating "dead spots" that cause the Arduino's analogRead() function to suddenly jump from 200 to 800 with a slight turn of the knob. Use the table below to diagnose your component's health.

Test Point Expected Good Reading Bad / Failing Reading Likely Hardware Cause
Pin 1 to Pin 3 (Total Track) 10kΩ (±20% tolerance, so 8kΩ to 12kΩ is acceptable) OL (Open Load) or 0Ω Snapped internal carbon track or wiper shorted to outer terminal.
Pin 1 to Pin 2 (Sweep Minimum) 0Ω to 50Ω (at full counter-clockwise rotation) >100Ω at mechanical limit Oxidized wiper contact or physical debris at the travel limit.
Pin 1 to Pin 2 (Sweep Mid-Range) Smooth, linear progression (e.g., ~5kΩ at 50% rotation) Sudden jumps, drops to OL, or erratic flickering Worn carbon track creating a "dead spot" (wiper loses physical contact).
Pin 1 to Pin 2 (Sweep Maximum) ~10kΩ (matching total track resistance) Reads significantly lower than Pin 1-3 total Internal short between wiper and outer pin, or incorrect taper (e.g., Audio taper).

For deeper theory on how these resistive tracks are manufactured and why tapers matter, refer to the All About Circuits guide on potentiometers.

Translating Hardware Measurements to Arduino ADC Code

Once your multimeter confirms the potentiometer is physically healthy, you must map its physical voltage output to the microcontroller's Analog-to-Digital Converter (ADC). A standard Arduino Uno (ATmega328P) uses a 10-bit ADC, meaning it maps the 0-5V input to integer values between 0 and 1023.

However, physical potentiometers generate electrical noise (wiper bounce) and the ADC itself is susceptible to high-frequency jitter. Writing robust potentiometer code for Arduino requires more than just a raw analogRead(). The code below implements an Exponential Moving Average (EMA) filter to smooth out minor hardware jitter without introducing the lag of a simple averaging array.


// Pin Definitions
const int POT_PIN = A0;

// EMA Filter Configuration
// Alpha determines smoothing. 0.1 = heavy smoothing, 0.9 = fast response.
const float ALPHA = 0.15; 
float filteredValue = 0.0;

void setup() {
  Serial.begin(115200);
  
  // Set ADC reference to default (5V on Uno, 3.3V on ESP32/Arduino Due)
  analogReference(DEFAULT);
  
  // Prime the filter with an initial physical reading to prevent startup lag
  filteredValue = analogRead(POT_PIN);
}

void loop() {
  // 1. Read the raw ADC value (0-1023 for 10-bit, 0-4095 for 12-bit ESP32)
  int rawValue = analogRead(POT_PIN);
  
  // 2. Apply Exponential Moving Average (EMA) filter
  filteredValue = (ALPHA * rawValue) + ((1.0 - ALPHA) * filteredValue);
  
  // 3. Map the smoothed value to a usable percentage (0-100%)
  // Note: Using 1023.0 for float math precision before casting to int
  int percentage = (int)((filteredValue / 1023.0) * 100.0);
  
  // 4. Constrain to handle edge-case ADC overshoots
  percentage = constrain(percentage, 0, 100);
  
  // Output for Serial Plotter
  Serial.print("Raw:");
  Serial.print(rawValue);
  Serial.print("\tFiltered:");
  Serial.print(filteredValue);
  Serial.print("\tPercent:");
  Serial.println(percentage);
  
  delay(20); // 50Hz sampling rate
}

For official documentation on how the Arduino ADC samples voltage and the implications of the analogRead() function, consult the Arduino analogRead() reference.

Common Mistakes That Give Misleading Readings

Even with a good meter and healthy code, bench technique can ruin your data. Here are the specific mistakes that yield misleading multimeter readings:

  • Measuring In-Circuit: If you leave the potentiometer wired to the Arduino's 5V and GND rails while measuring resistance, the multimeter's test voltage will backfeed into the microcontroller. More importantly, parallel resistances (like the ATmega328P's internal pull-up resistors) will artificially lower your ohm reading. Fix: Always remove at least one leg of the potentiometer from the breadboard before testing resistance.
  • The "Finger Resistance" Error: The human body has a resistance ranging from 1kΩ (sweaty skin) to 100kΩ (dry skin). If you grip the metal probe tips and the potentiometer pins simultaneously with your bare fingers, your body acts as a parallel resistor. On a 10kΩ pot, this can skew your reading by 20% to 50%. Fix: Hold the probes by the insulated plastic grips, or use alligator-clip test leads.
  • Ignoring the Taper: If your multimeter reads 5kΩ at the physical midpoint, but your Arduino code expects a linear mapping, you might be using an Audio (C-taper) potentiometer. Audio pots are logarithmic; they read roughly 10% to 20% of total resistance at the mechanical midpoint. Fix: Check the back of the pot. A "B" prefix (e.g., B10k) means Linear. An "A" or "C" prefix means Logarithmic/Audio.

Frequently Asked Questions

Why is my potentiometer code for Arduino jumping around?

Jumping values are usually caused by "wiper bounce"—microscopic physical gaps in the carbon track that cause the resistance to momentarily spike to infinity (OL) before reconnecting. The Arduino's ADC captures these microsecond spikes as massive voltage jumps. You can fix this in hardware by adding a 0.1µF ceramic capacitor between the wiper pin and GND (acting as a low-pass RC filter), or in software by implementing the EMA filter provided in the code block above.

How do I map a 10k potentiometer to a 0-100 percentage in Arduino?

Use the built-in map() function, but be aware of integer math truncation. The syntax is map(rawValue, 0, 1023, 0, 100). However, because map() does not round up, a raw value of 1015 might map to 99 instead of 100. For precise UI controls, it is better to use floating-point math: int percent = (rawValue * 100.0) / 1023.0; and then apply the constrain() function to lock the boundaries.

Can I use a 100k or 1k potentiometer instead of 10k for Arduino?

You can, but 10kΩ is the engineering sweet spot. The ATmega328P ADC is optimized for an analog source impedance of 10kΩ or less. If you use a 100kΩ pot, the internal sample-and-hold capacitor won't have enough time to charge fully during the ADC conversion clock cycles, resulting in inaccurate, low-biased readings. If you use a 1kΩ pot, it will draw 5mA of constant current (wasting power and generating heat) without improving ADC accuracy. If you must use a 100kΩ pot, buffer the wiper signal with an op-amp voltage follower.

What does a dead spot on a potentiometer look like on a multimeter?

When sweeping the dial with your probes on Pin 1 and Pin 2, a dead spot will manifest as the display suddenly flashing "OL" (Open Load) or jumping erratically from a low number (e.g., 2.1kΩ) straight to a high number (e.g., 8.5kΩ) without passing through the intermediate values. On an oscilloscope or Arduino Serial Plotter, this looks like a vertical cliff or a complete dropout to 0V/5V.