class ADCWiPy – analog to digital conversion 类ADCWiPy – 拟到数字的转换 =============================================


This class is a non-standard ADC implementation for the WiPy. It is available simply as machine.ADC on the WiPy but is named in the documentation below as machine.ADCWiPy to distinguish it from the more general machine.ADC class. 这个类是WiPy的非标准ADC实现。 它可以简单地称为’ ‘ machine。“ADC”在WiPy上却被命名为 下面的文档为’ ‘ machine。把它和…区分开来 更普遍的:裁判:“机器。ADC <机器。ADC >”类。

Usage:: 用法:

import machine

adc = machine.ADC()             # create an ADC object
adc = machine.ADC()             # 创建一个ADC对象
apin ='GP3')   # create an analog pin on GP3
apin ='GP3')   # 在GP3上创建一个模拟引脚
val = apin()                    # read an analog value
val = apin()                    # 读取模拟值

Constructors 构造函数 ————

class machine.ADCWiPy(id=0, \*, bits=12)

Methods 方法 ——-, \*, pin)

Create an analog pin. If only channel ID is given, the correct pin will be selected. Alternatively, only the pin can be passed and the correct channel will be selected. Examples:: 创建模拟引脚。如果只有通道ID是给定的,正确的pin将 被选中。或者,只有大头针可以通过和正确的 频道将被选择。例子:

# all of these are equivalent and enable ADC channel 1 on GP3
# 所有这些都是等效的,并在GP3上启用ADC通道1
apin =
apin ='GP3')
apin =, pin='GP3')

Enable the ADC block. 启用ADC块。


Disable the ADC block. 禁用ADC块。

class ADCChannel — read analog values from internal or external sources 类ADCChannel — 从内部或外部源读取模拟值 =========================================================================

ADC channels can be connected to internal points of the MCU or to GPIO pins. ADC channels are created using the method. ADC通道可以连接到MCU的内部点或GPIO引脚上。 ADC通道是使用ADC创建的。通道的方法。


Fast method to read the channel value. 快速读取通道值的方法。


Read the channel value. 读取通道值。


Re-init (and effectively enable) the ADC channel. 重新init(并有效地启用)ADC通道。


Disable the ADC channel. 禁用ADC通道。