from machine import ADC, Pin # import ADC and Pin classes
import time # import time module
adc = ADC(26) # create ADC object from Pin26
try: # if have no error, run the program between try: and except:
while True: # create an infinite loop
adcValue = adc.read_u16() # read ADC value
voltage = '{:.1f}'.format(adcValue / 65535.0 * 3.3) # calculate voltage
# print ADC value and voltage
print("ADC Value:", adcValue, "Voltage:", voltage, "V")
time.sleep(0.1) # sleep 100 milliseconds
except: # if have error, run the program between except:
pass # do nothing