CNAP

Potentiometer Reference

A rotary variable resistor used as an analog input. Turning the knob changes the voltage on the SIG (wiper) pin.

Pin names

NameDescription
GNDGround
SIGSignal (wiper) — connect to an analog input pin
VCCPower (5V)

Attributes

This component has no configurable attributes.

Usage

Connect VCC to 5V, GND to GND, and SIG to an analog input pin (A0–A5 on an Uno). Read the value with analogRead(), which returns 0–1023.

const int POT_PIN = A0;

void setup() {
  Serial.begin(9600);
}

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

To use the value for PWM output (0–255), scale it with map():

int brightness = map(analogRead(POT_PIN), 0, 1023, 0, 255);
analogWrite(LED_PIN, brightness);

Examples

DescriptionAttrs
Default potentiometer{}

See also