Potentiometer

From Sketching with Hardware at LMU Wiki
Revision as of 08:51, 11 June 2024 by Mayersven (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

Poti.PNG

Slider

Slider.PNG

How to connect it electrically[edit]

PotiConnection1.png

How to control it in MicroPython[edit]

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


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

PotiConnection2.jpg


Schematic drawing:

PotiConnection1.png

Related Tutorial Videos[edit]