# Tutorial – Measure Voltage Across a Potentiometer Introduction

This tutorial explains how to measure a voltage across a potentiometer (POT) and display the results in the serial monitor.  The measured voltage will vary between 0 and 5 VDC as you adjust the potentiometer.

Suggested Applications

• Volume control
• Position sensor
• Liquid Crystal Display (LCD) contrast or brightness control

Parts List

• Arduino or Arduino clone (a Hobbyduino Mini V3 is used for this tutorial)
• 10K potentiometer
• Hobbyduino Proto Plug (optional) or breadboard
• FTDI Basic (Sparkfun)

Basic Wiring  Code

```/* Reads voltage across a 10K Pot and displays the results in the
serial monitor */

#define  POTpin  0                     // Potentiometer connected to analog pin 0

void setup()
{
Serial.begin(57600);                 // Set serial to 9600 baud
}

void loop()
{
float volts = (val/1023.0) * 5.0;    // Calculate the ratio
Serial.print("Volts DC: ");
Serial.println(volts);               // Print value in volts
delay(1000);                         // Delay 1sec
}```

Upload the sketch to the Arduino and open the serial monitor (be sure the baud rate in the serial monitor matches that of the sketch).

Measured Voltage: Discussion

Basically, a potentiometer is a resistor setup as a variable voltage divider.  There are two terminals and a sliding contact (also called a wiper).  The resistance increases or decreases as you slide (rotate) the wiper from one end to the other.

The voltage level measured by analog pin 0 varies as you adjust the position of the wiper.  The ATMega328 used on the Hobbyduino Mini contains a 6 channel, 10-bit analog to digital converter (A/D).  The A/D maps input voltages between 0 and 5 VDC into an integer value between 0 and 1023.  This conversion is achieved by the Arduino analogRead() function.