4.6 Potentiometer Interface
4.6.1 Definition of a Potentiometer
A potentiometer is a variable resistor with three terminals. It can be used to produce a variable voltage that an Arduino can read through an analog input.
A typical potentiometer has:
- VCC – connected to the supply voltage.
- GND – connected to ground.
- Wiper – connected to an Arduino analog input.
The wiper voltage changes as the knob is rotated.
4.6.2 Connecting a Potentiometer
A typical connection is:
|
Potentiometer Terminal |
Arduino |
|
First terminal |
5V |
|
Middle terminal |
A0 |
|
Third terminal |
GND |
The exact direction of increase or decrease depends on which outer terminal is connected to 5 V.
4.6.3 Reading the Potentiometer

Example:
int potPin = A0;
int potValue;
void setup() {
Serial.begin(9600);
}
void loop() {
potValue = analogRead(potPin);
Serial.println(potValue);
delay(200);
}
As the potentiometer is rotated, the analog reading changes.
4.6.4 Using a Potentiometer to Control LED Brightness
A potentiometer can control the brightness of an LED.
int potPin = A0;
int ledPin = 9;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
int potValue = analogRead(potPin);
int brightness = map(potValue, 0, 1023, 0, 255);
analogWrite(ledPin, brightness);
}
The map() function converts the potentiometer reading from the range 0–1023 into the PWM range 0–255.
How the System Works
Potentiometer → Analog Input → Arduino Processing → PWM Output → LED
When the potentiometer is rotated:
- The potentiometer produces a different voltage.
- The Arduino reads the voltage through A0.
- The Arduino converts the reading into a numerical value.
- The value is mapped to a PWM range.
- The PWM signal controls LED brightness.


