##############################################################
# Potentiometer Interface #
##############################################################
#
# Potentiometer Interface with Raspberry Pi Pico / W / 2 / w2 (Hardware & Simulation)
#
# Check out the link for Code explanation and Hardware details
# Link:
# http://tech.arunkumarn.in/blogs/raspberry-pi-pico/getting-started-reading-analog-values-from-a-potentiometer-with-raspberry-pi-pico-micropython/
#
#
from machine import Pin, ADC
import time
time.sleep(1)
# Potentiometer connected to GPIO 26 (ADC 0)
# ADC PIN are GPIO 26, 27, 28.
pot = ADC(Pin(26))
while True:
value = pot.read_u16()
print(f"POT {value=}")
position = (value / 65535) * 100
print(f"{position=:0.2f} %")
time.sleep(2)