A potentiometer may look like a basic knob with three pins, but it is one of the clearest ways to see how a microcontroller interprets the physical world. Turn the shaft and the voltage changes. Feed that changing voltage into an analog input, and the microcontroller converts the movement into a number your program can use.
That is the practical foundation of how to read a potentiometer with a microcontroller. The potentiometer is wired as a voltage divider; the center wiper sends a variable voltage to an ADC pin, and the analog-to-digital converter translates that signal into a digital value.
I like this setup because it teaches more than just potentiometer wiring. It also introduces ADC resolution, voltage references, analog noise, input limits, and value mapping in one simple circuit. Once the concept makes sense, the same approach becomes useful for Arduino, ESP32, Raspberry Pi Pico, STM32, and many other microcontroller projects.
Table of Contents
ToggleHow Does a Potentiometer Produce an Analog Voltage?
A standard rotary potentiometer normally has three terminals. The two outer terminals connect to opposite ends of an internal resistive track, while the center terminal connects to a moving contact known as the wiper.
When I connect one outer terminal to VCC and the other to ground, the potentiometer acts as a voltage divider. Rotating the shaft moves the wiper across the resistive track and changes the voltage available at the center terminal.
For example, with a 5V supply, the wiper may produce approximately 0V at one end, 2.5V around the midpoint, and close to 5V at the other end.
The microcontroller does not need to measure the resistance directly. It simply measures the changing wiper voltage.
How Should You Wire a Potentiometer to an ADC Pin?
The normal three-wire connection is straightforward. One outer terminal connects to the microcontroller’s supply voltage, the opposite outer terminal connects to ground, and the center wiper connects to an ADC-capable analog input.
On an Arduino Uno, I might connect the wiper to A0. On an ESP32 or Raspberry Pi Pico, I would choose one of the board’s designated ADC pins.
If the potentiometer value decreases when I turn the knob clockwise, I can swap the two outer connections. The center wiper stays connected to the analog input.
A 10 kΩ linear potentiometer is a common choice for general microcontroller projects because it provides a practical balance between power consumption and ADC input performance.
How Does the ADC Convert Potentiometer Voltage Into a Number?

The Analog-to-Digital Converter samples the voltage on the input pin and converts it into a digital value.
The size of that digital range depends on ADC resolution.
A classic Arduino Uno uses a 10-bit ADC, giving 1,024 possible levels. The reported range normally runs from 0 through 1023. With a 5V reference, a voltage near zero produces a value near 0, approximately 2.5V produces a value near 512, and a voltage near the reference produces a value close to 1023.
A 12-bit ADC provides 4,096 levels, commonly represented by values from 0 through 4095. This higher resolution allows the microcontroller to distinguish smaller voltage changes.
I always check the documentation for the exact board because ADC resolution, reference voltage, attenuation settings, and usable input range can vary.
How Do You Read a Potentiometer With Arduino Code?
For a basic test, I only need to read the analog input and print the value to the Serial Monitor.
const int potPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int potValue = analogRead(potPin);
Serial.println(potValue);
delay(50);
}
As I rotate the knob, I should see the ADC value rise or fall. On a standard Arduino Uno, the reading should generally travel between values close to 0 and 1023.
This simple test is useful before connecting the potentiometer reading to a motor, LED, servo, or another output.
When developing microcontroller projects with AI-assisted programming tools, protecting sensitive information is just as important as getting the code to work correctly.
Following practical guidance on using AI coding tools without exposing private data can help developers avoid sharing API keys, credentials, private configuration files, or proprietary code while debugging and refining embedded applications.
How Can You Convert an ADC Reading Into Voltage?
Raw ADC values are useful for programming, but sometimes I want to know the actual input voltage.
For a 10-bit ADC using a 5V reference, I can calculate it with:
float voltage = potValue * (5.0 / 1023.0);
If the ADC reading is approximately 512, the calculated voltage will be close to 2.5V.
For a 12-bit system with a 3.3V reference, the calculation may look like this:
float voltage = potValue * (3.3 / 4095.0);
The important point is to use the actual ADC resolution and reference conditions for the board instead of assuming every microcontroller behaves like an Arduino Uno.
The same approach of reading inputs, processing values, and automating responses can extend beyond embedded electronics into everyday workplace tasks.
Exploring Python automation projects for office workers offers practical examples of how programming can handle repetitive calculations, organize data, and streamline routine workflows. Although the applications differ, both microcontroller programming and Python automation rely on converting input data into useful, actionable results.
Can You Convert the Potentiometer Reading Into a Percentage?

Yes. Converting the raw value into a percentage is useful when the potentiometer represents something a user adjusts, such as brightness, speed, sensitivity, or a menu setting.
For a 10-bit Arduino reading, I could write:
int percentage = map(potValue, 0, 1023, 0, 100);
The resulting value ranges approximately from 0% to 100%.
The same principle can map the ADC reading to servo angles, PWM duty cycles, timing intervals, or other useful control ranges.
What Changes With 3.3V and 5V Microcontrollers?
Voltage compatibility is one of the most important details when learning how to read a potentiometer with a microcontroller.
Traditional Arduino Uno boards commonly operate around 5V, while many modern development boards use 3.3V logic.
If I use a 3.3V-only ADC, I normally connect the potentiometer between 3.3V and ground. That keeps the wiper voltage within the safe input range.
I would not automatically power the potentiometer from 5V and connect its wiper to a 3.3V ADC. Exceeding the permitted analog input voltage can cause inaccurate readings or potentially damage the microcontroller.
Why Does a Potentiometer Reading Jump Around?
Small ADC fluctuations are normal. Electrical noise, supply variations, breadboard connections, long wires, and mechanical contact inside the potentiometer can all affect the measurement.
One simple way I smooth the result is by averaging several samples:
long total = 0;
for (int i = 0; i < 10; i++) {
total += analogRead(A0);
}
int averageValue = total / 10;
Keeping analog wiring short and maintaining a solid shared ground also helps. In some circuits, a small capacitor between the wiper and ground can reduce high-frequency noise.
Software techniques such as averaging, filtering, or adding a small deadband are particularly useful when the potentiometer controls something that should not constantly react to tiny ADC changes.
Should You Use a Linear or Logarithmic Potentiometer?
For most microcontroller controls, I prefer a linear potentiometer.
With a linear taper, the change in wiper voltage roughly follows the knob’s physical position. A halfway position therefore tends to produce about half the available voltage.
Logarithmic potentiometers are commonly associated with audio volume controls. They can still connect to an ADC, but their output does not change linearly with shaft position.
For general electronics projects, user controls, and sensor experiments, a linear taper is usually easier to understand and program.
What Can You Control With a Potentiometer?
Once the microcontroller has the ADC value, that number can control many parts of a project.
I can use it to adjust LED brightness through PWM, change servo position, set a motor-speed target, adjust an alarm threshold, select a delay time, tune sensor sensitivity, or create a physical control for a menu.
For example:
int brightness = map(potValue, 0, 1023, 0, 255);
analogWrite(9, brightness);
This converts the potentiometer’s 10-bit ADC range into a typical 8-bit PWM range.
A potentiometer can also serve as a manual input for monitoring and adjusting energy-related parameters in a Raspberry Pi project.
For practical examples of combining hardware inputs, sensor readings, and data collection, explore these Raspberry Pi projects for home energy monitoring. Such projects illustrate how physical controls and electronic measurements can contribute to interactive systems for understanding household energy use.
What Are the Most Common Potentiometer Wiring Mistakes?
A common mistake is using only two terminals when the goal is to create a variable analog voltage. For normal ADC measurements, all three terminals are generally used so the potentiometer functions as a voltage divider.
Another problem is connecting the wiper to a GPIO pin that does not support analog conversion.
I also check for incorrect supply voltage, missing ground connections, loose breadboard wires, and assumptions about ADC resolution. If the results still look wrong, measuring the wiper voltage with a multimeter can help determine whether the problem is in the circuit or the software.
Frequently Asked Questions
1. What value potentiometer is best for a microcontroller?
A 10 kΩ linear potentiometer is a common starting point for Arduino and many other development boards. Always check the microcontroller’s ADC recommendations if you are designing a more precise circuit.
2. Why does my potentiometer only read from 0 to 1023?
A range from 0 through 1023 usually indicates a 10-bit ADC. Higher-resolution ADCs can produce larger numerical ranges.
3. Can I connect a potentiometer directly to an analog pin?
Yes, when it is wired correctly as a voltage divider, and its output voltage stays within the permitted range of the ADC input.
4. How do I know which potentiometer terminal is the wiper?
On most standard three-terminal rotary potentiometers, the center terminal is the wiper. I check the component’s datasheet when the pin arrangement is uncertain.
5. Is how to read a potentiometer with a microcontroller the same on every development board?
The voltage-divider principle remains the same, but ADC voltage limits, resolution, reference voltage, and software functions can vary between boards.
Final Thoughts
A potentiometer is one of the most practical components I use when explaining analog inputs because the relationship between movement, voltage, and software is easy to observe.
Once the two outer terminals establish the voltage divider and the center wiper feeds an ADC input, the microcontroller can turn knob position into digital information. From there, software can convert that reading into voltage, percentage, PWM output, servo position, motor control, or almost any adjustable parameter.
Understanding this simple circuit also makes it easier to work with other analog devices. Light sensors, joysticks, pressure sensors, thermistors, and many other components ultimately rely on the same basic idea: measure a changing electrical signal and convert it into data that software can process.



