import board
import analogio
import time
# Set up the potentiometer on GP26 as an analog input
pot = analogio.AnalogIn(board.GP26)
def get_voltage(pin):
"""Convert the analog value (0-65535) to a voltage (0-3.3V)"""
return (pin.value * 3.3) / 65535
while True:
# Read the potentiometer value
pot_value = pot.value
voltage = get_voltage(pot)
# Print the values to the Serial Monitor
print(f"Potentiometer Value: {pot_value}, Voltage: {voltage:.2f}V")
time.sleep(0.5) # Small delay for readability