Knob-controlled variable resistor (linear potentiometer)
The information below also applies to the slide potentiometer.
|SIG||Output, connect to an analog input pin|
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.
|value||Initial value of the potentiometer, between 0 and 1023||"0"|
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:
You can run the example on Wokwi. Observe how the plotter graph changes as you move the potentiometer's knob.
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.