Potentiometer

In this project, you'll learn how a potentiometer works.

A potentiometer is simply a variable resistor, i.e., a resistor whose resistance value can be changed. A dial on the potentiometer is used to adjust the resistance value. An analog input pin on the Arduino board is used to read this analog value from the potentiometer.

Parts needed:
  • Arduino
  • Potentiometer 10K Ω
  • Wires
  • Breadboard
Potentiometer or Potentiometer
1 Making the connections
  • Connect one end of the potentiometer to positive 5V on the Arduino.
  • Connect the middle leg of the potentiometer to pin A0 on the Arduino.
  • Connect the other end of the potentiometer to GND on the Arduino board.
Potentiometer schematic
Potentiometer connections
2 Create a new Bare Minimum program by selecting File from the menu
  • then select Examples
  • then select Basics
  • then select BareMinimum

Then type in this program.


The Serial.begin command prepares the serial monitor for printing outputs. The number 9600 is the speed at which the monitor will communicate at.

The analogRead command reads in an analog value (a number between 0 and 1023) from the specified analog input pin A0. This number is assigned and stored in the value variable.

The Serial.println command prints out the number that is stored in the value variable to the monitor.
Potentiometer program
3 Open the serial monitor by clicking on the Serial Monitor icon.

Make sure that the baud rate (number at the bottom right corner of the monitor) matches the number specifed in the Serial.begin command. In this case, it is 9600.
Monitor output
4 Run the program and adjust the potentiometer.

Notice the numbers in the serial montior change as you rotate the dial.