> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/wokwi/wokwi-docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Potentiometer

> Knob-controlled variable resistor (linear potentiometer)

Knob-controlled variable resistor (linear potentiometer)

The information below also applies to the [slide potentiometer](/parts/wokwi-slide-potentiometer).

## Pin names

<ParamField path="GND" type="Ground">
  Ground
</ParamField>

<ParamField path="SIG" type="Analog Output">
  Output, connect to an analog input pin
</ParamField>

<ParamField path="VCC" type="Power">
  Supply voltage
</ParamField>

<Note>
  Wokwi does **not** support full analog simulation, so you will get the same
  results even if you don't connect the GND/VCC pins.

  This may change in the future, so it's a good idea to connect GND/VCC anyway.
</Note>

## Attributes

<ParamField path="value" type="string" default="0">
  Initial value of the potentiometer, between 0 and 1023
</ParamField>

## Using the Potentiometer in Arduino

Connect the SIG pin to one of Arduino's analog input pins (A0, A1, …). Then use the `analogRead()` function to read the current value of the potentiometer.

The following code example assumes that the potentiometer is connected to A0.
It will read and print the current value of the potentiometer every 100 milliseconds:

```cpp theme={null}
void setup() {
  Serial.begin(115200);
  pinMode(A0, INPUT);
}

void loop() {
  int value = analogRead(A0);
  Serial.println(value);
  delay(100);
}
```

You can [run the example on Wokwi](https://wokwi.com/projects/298685457758159369). Observe how the plotter graph changes as you move the potentiometer's knob.

## Keyboard control

You can control the potentiometer with the keyboard:

* Left / Right - fine movement
* Page Up / Page Down - coarse movement
* Home / End - move to the start (0) or the end (1023) of the range

You'll need to click on the potentiometer before using these keyboard shortcuts.

## Automation controls

The potentiometer can be controlled using [Automation Scenarios](/wokwi-ci/automation-scenarios). It exposes the following controls:

<ParamField path="position" type="float">
  Moves the potentiometer to the given position, between 0.0 and 1.0
</ParamField>

The following example set the potentiometer to the middle position:

```yaml theme={null}
  - set-control:
      part-id: pot1
      control: position
      value: 0.5
```

## Simulator examples

* [Knob](https://wokwi.com/projects/344892191015961170) - Control a [servo](/parts/wokwi-servo) with a potentiometer
* [Plot](https://wokwi.com/projects/298685457758159369) - Plot potentiometer values in the Serial Plotter
* [Block shooter](https://wokwi.com/projects/291960996581343753) - Breakout style game
