Potentiometer

From Sketching with Hardware at LMU Wiki
Jump to navigation Jump to search

Description[edit]

A potentiometer is a resistor that can be mechanically changed. Typically form factors are knobs (turn to change) or sliders. The change of resistance is either linear (resistance changes linear with the angle or distance) or logarithmic.

Potentiometer

Slider

How to connect it electrically[edit]

How to control it in MicroPython[edit]

#ESP32 or ESP8266
from machine import Pin, ADC
from time import sleep
pot = ADC(Pin(34))
pot.atten(ADC.ATTN_11DB)
while True:
  pot_value = pot.read()
  print(pot_value)
  sleep(0.5)
#Raspberry Pi Pico
from machine import Pin, ADC
from time import sleep
pot = ADC(Pin(26))
conversion_factor = 3.3 / (65535)
while True:
  pot_value = pot.read_u16() * conversion_factor
  print(pot_value)
  sleep(0.5)


Here the voltage of Pin 34 (for the ESP) or on Pin GP26 (for the Pico) is manipulable with the poti:


Schematic drawing:

Related Tutorial Videos[edit]