Skip to main content\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\Q}{\mathbb Q}
\newcommand{\R}{\mathbb R}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 3.9 Analog to digital converter (ADC)
Subsection 3.9.1 Reading values from the ADC
from machine import ADC, Pin
from time import sleep
adc = ADC(Pin(35))
# Can change the voltage range with
#adc.atten(ADC.ATTN_11DB)
while True:
raw = adc.read()
volts = raw * 1.0 / 4096
print("measured {} V ({})".format(volts, raw))
sleep(0.1)