from machine import ADC
from time import ticks_ms, sleep
# Read the voltage from Pin 26
adc = ADC(0)
old_meas = 0
# Read the ADC and work out if maximum peak.
while True:
try:
adc_meas = adc.read_u16()
if adc_meas > 0 and (old_meas != adc_meas):
print(f"ADC: {adc_meas} at {ticks_ms()}")
old_meas = adc_meas
except KeyboardInterrupt:
break
print("Finished")