Linear (Slide) Potentiometer

A slide potentiometer is a variable resistor with a sliding knob: the wiper voltage tells the board where the knob is.

Sensors6 blocksMicroPythonC++
Linear Pot

At a glance

Pins and properties exactly as the circuit editor and simulator define this part. The text below explains how to use them.

Pinout

Pinout of the Linear Pot, drawn as in the circuit editor. Select a label to see that pin in the table below.

Pins

Pins of this part
PinLabelType
AGNDSignal in
WAOAnalog out
BVCCSignal in

Properties

What you can change in the Property Inspector.

Properties of this part
PropertyRange or choicesDefault
Resistance100 to 1000000 Ω10000 Ω
Position0 to 1023512

A linear potentiometer works like a rotary one, but the knob slides along a track. It is a voltage divider you can adjust by hand: the middle pin (the wiper) gives a voltage between 0 V and the supply voltage, depending on the knob position. In the simulator you drag the knob while the simulation runs.

Wiring

PinConnect to
End AGND
Wiper W (output)An analog input pin of the board
End BVCC (the board's logic voltage, 3.3 V or 5 V)

Do not connect the wiper to VCC or GND directly: it is the signal output.

Reading it

The analog pin reads a number that grows with the knob position (0 at the A end, the maximum at the B end). The Linear Potentiometer blocks read it for you:

  • setup sets the analog pin once.
  • read returns the position as a percentage (0 to 100) or the raw reading.
  • map to range scales the position to your own range, for example 0 to 180 for a servo angle.
  • voltage returns the voltage at the pin.
  • is above and is between give true or false, for conditions such as "when the slider is past 70 %".

Properties

The track resistance sets how much current the divider draws; 10 kΩ is a good default. The position is the knob position and can be dragged on the canvas.

Troubleshooting

  • The reading is stuck at 0 or the maximum: check that the two ends are on GND and VCC and the wiper is on an analog-capable pin.
  • The reading jumps around: use a pin that is not shared with Wi-Fi on boards where some analog pins stop working while Wi-Fi is on.

Block reference

Drawing the blocks…

Linear (Slide) Potentiometer — OMS Parts