Send variable input til din microcontroller med et potentiometer
Potentiometer
Potentiometeret afsender en variabel spænding som kan aflæses på esp32 via en ADC pin. Spænding der bliver sendt via potentiometerets signal ben vil varierer efter hvor meget potentiometer er roteret.
Potentiometer har det forhold at procentdelen af maxspændingen og procentdelen af grader potentiometeret er drejet vil være det samme. Så hvis potentiometer er drejet 50%, vil det kunne måles en ADC værdi der svarer til en spænding på 50%.
Tekniske specifikationer
Operativ spænding | 3.3V - 5V |
Interface | Analog |
Dimensioner | 34mm x 20mm x 28mm |
Vægt | 7g |
Kode Eksempel
from machine import Pin, ADC
from time import sleep
pot = ADC(Pin(36))
pot.atten(ADC.ATTN_11DB)
pot.width(ADC.WIDTH_12BIT)
while True:
pot_val = pot.read()
spaending = pot_val*3.3/4095
print("Analog potentiometer vaerdi: ", spaending)
sleep(0.1)
Pinout
Pinout
Nummer | Navn | Function |
---|---|---|
1 | G (GND) | Negativ forsyning |
2 | V (VCC) | Positiv forsyning |
3 | S (Signal) | Signal (analog) |
Hvordan fungerer den?
Referencer
Billeder og forklaring: https://randomnerdtutorials.com/esp32-esp8266-analog-readings-micropython/
Alternativ billeder og forklaring: https://microcontrollerslab.com/esp32-esp8266-adc-micropython-measure-analog-readings/
Potentiometer og LED: https://microcontrollerslab.com/micropython-pwm-with-esp32-and-esp8266-led-fading-brightness-control-examples/
Inspiration og kommentarer
Er du faldet over links eller lignende, som kan være relevant for dine medstuderende så send os en mail på nini@kea.dk