.. currentmodule:: machine
Note
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 :ref:`machine.ADC <machine.ADC>` class.
Usage:
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
.. method:: ADCWiPy.channel(id, *, 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:: # all of these are equivalent and enable ADC channel 1 on GP3 apin = adc.channel(1) apin = adc.channel(pin='GP3') apin = adc.channel(id=1, pin='GP3')
.. method:: ADCWiPy.init() Enable the ADC block.
.. method:: ADCWiPy.deinit() Disable the ADC block.
ADC channels can be connected to internal points of the MCU or to GPIO pins. ADC channels are created using the ADC.channel method.
.. method:: adcchannel() Fast method to read the channel value.
.. method:: adcchannel.value() Read the channel value.
.. method:: adcchannel.init() Re-init (and effectively enable) the ADC channel.
.. method:: adcchannel.deinit() Disable the ADC channel.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。