Skip to content

Potentiometer

Component Potentiometer
Type Input
Function Setting a volume, scrolling in a menu, ... lots of rotating options.

Introduction

A potentiometer is a type of variable resistor that is used to control the voltage in a circuit. It has three pins: the input pin, the output pin, and the wiper pin. The resistance between the input and output pins is constant, while the resistance between the wiper pin and the output pin changes based on the position of the wiper. This allows you to control the voltage in a circuit by adjusting the position of the wiper.

Pin Description

The potentiometer has three pins: the input pin, the output pin, and the wiper pin. The input pin is connected to the power supply, the output pin is connected to ground, and the wiper pin is connected to an analog pin on a microcontroller. You can use the analogRead function to read the voltage at the wiper pin and determine the position of the wiper.

Code Example

The following code example demonstrates how to read the voltage at the wiper pin of a potentiometer using an Arduino board.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#define POT_PIN A0 // define the potentiometer pin

void setup() {
  Serial.begin(9600); // start serial communication at 9600 bps
}

void loop() {
  int potValue = analogRead(POT_PIN); // read the value from the potentiometer
  float voltage = potValue * (5.0 / 1023.0); // convert the value to voltage
  Serial.println(voltage); // print the voltage to the serial port
  delay(100); // wait for 100ms
}

(This example uses the Serial library to print the voltage to the serial port. You can view the output using the Serial Monitor in the Arduino IDE.)