from machine import ADC, Pin
import time
# Define the ADC pin
pot_pin = ADC(Pin(26)) # GP26 is ADC0 on the Raspberry Pi Pico
while True:
# Read the value from the potentiometer
pot_value = pot_pin.read_u16()
# Convert the value to a range of 0 to 100
pot_percent = pot_value / 65535 * 100
# Print the raw value and the percentage
print("Raw ADC value: ", pot_value)
print("Potentiometer percentage: {:.2f}%".format(pot_percent))
# Wait for a short time before the next read
time.sleep(0.5)