Back to Tutorials Page


A POTENTIOMETER is a three-terminal resistor with a sliding contact that forms an adjustable voltage divider. If only two terminals are used (one side and the wiper), it functions as a variable resistor or Rheostat. Potentiometers are commonly used to control electrical devices, such as the volume or tone control of an amplifier. Potentiometers are rarely used to directly control significant power, but rather are primarily used to adjust the level of small analog signals or a control input for electronic circuits. We'll use a potentiometer in this way, as an analog input to control the flash rate of an LED connected to a DIGITAL OUT pin on the Arduino.

We will connect all three contacts of the POTENTIOMETER to the Arduino. The first connection goes from one of the outer pins of the POTENTIOMETER to GROUND. The second connection goes from the other outer pin of the potentiometer to +5VDC. The final connection is made from the center pin of the potentiometer to the ANALOG 0 Pin on the Arduino. We also connect an LED with a current limiting resistor to DIGITAL PIN 13 (see LED Blink for reference).

In this example, we've chosen to use a Potentiometer with a male header soldered to the tabs. This creates a very stable and easy to use attachment for the Potentiometer to the breadboard and is recommended, though any Potentiometer chosen will work fine (as long as it is the correct value - 10K OHMS). In the photo below, we see examples of a few different types of potentiometers - the first is a thumbwheel type and will fit directly into the breadboard. The second is the one we are using with the header pins soldered to the tabs. The third is another panel mount Potentiometer with leads soldered to the tabs, which would be plugged into the breadboard. In this example, we are using the Modern Devices Arduino, which has male headers for the 6 Analog In channels. We are using a lead with one female plug attached to one end to fit into the Analog 0 pin on the board.


// This example flashes an LED on and off at a rate determined by the
// analog input value read on ANALOG IN 0 based on the position of the
// potentiometer. When the potentiometer is turned all the way clockwise, the
// analogRead function will return a value of 0. When the potentiometer is turned
// all the way counterclockwise, the analogRead function will return a value of
// 1023. This value will be used to determine one cycle of delay time for the LED
to be on and then off. The value of potPIN is printed into the Arduino Serial
// Window so its value change can be monitored along with the change in flash
// rate of the LED

int potPIN = 0;  // select the input pin for the potentiometer
int ledPIN = 13; // select the output pin for the LED
int potVAL = 0;  // variable to store the value coming from the potentiometer

void setup() {
Serial.begin(9600);      // set the baud rate for the serial window
pinMode(ledPIN, OUTPUT); // declare the ledPin as an OUTPUT, ANALOG IN is an
                         // input by default

void loop() {
potVAL = analogRead(potPIN); // read the value from the potentiometer
potVAL = (potVAL/2 + 16);    // scale and shift the potVAL to be a useful
                             // flashrate (barely visible to 511ms)
digitalWrite(ledPIN, HIGH);  // set the ledPIN HIGH, which turns on the LED
delay(potVAL);               // do nothing for (potVAL) milliseconds
digitalWrite(ledPIN, LOW);   // set the ledPIN LOW, which turns off the LED
delay(potVAL);               // do nothing for (potVAL) milliseconds
Serial.println(potVAL);      // print potVAL in the arduino serial window