class ADC – analog to digital conversion: read analog values on a pin¶
import pyb adc = pyb.ADC(channel) # create an analog object on one of the 4 ADC channels val = adc.read() # read an analog value
Create an ADC object on the given channel. Each channel is associated to a specific pin. For more info check the pinout and alternate functions table. This allows you to then read analog values on that pin.
ADC pin input range is 0-1.4V (being 1.8V the absolute maximum that it can withstand). When GPIO2, GPIO3, GPIO4 or GPIO5 are remapped to the ADC block, 1.8 V is the maximum. If these pins are used in digital mode, then the maximum allowed input is 3.6V.