ADC类 – 模数转换¶
用法:
import machine
adc = machine.ADC() # create an ADC object
apin = adc.channel(pin='GP3') # create an analog pin on GP3
val = apin() # read an analog value
构造函数¶
-
class
machine.
ADC
(id=0, *, bits=12)¶ 创建与给定引脚相关联的ADC对象。 这样你就可以读取引脚上的模拟值。 有关更多信息,请查看 pinout and alternate functions table.
警告
ADC pin input range is 0-1.4V (being 1.8V the absolute maximum that it can withstand). When GP2, GP3, GP4 or GP5 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. ADC引脚输入范围为 0-1.4V (1.8V为它所能承受的绝对最大值)。 当GP2、GP3、GP4或GP5被重映射到ADC块时,1.8V为最大值。 如果这些引脚在数字模式下使用,那么最大允许输入是3.6V。