from machine import ADC, Pin
from time import sleep
# Setup the potentiometer on GPIO 34
potentiometer = ADC(Pin(18))
potentiometer.atten(ADC.ATTN_11DB) # Set the attenuation to read a wider range (0-3.3V)
potentiometer.width(ADC.WIDTH_10BIT) # Set ADC resolution (0-1023)
while True:
pot_value = potentiometer.read() # Read potentiometer value (0-1023)
print("Potentiometer Value:", pot_value)
sleep(0.1) # Delay for 100ms