Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
73 lines (46 loc) · 1.96 KB

File metadata and controls

73 lines (46 loc) · 1.96 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

class ADC -- analog to digital conversion

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

Constructors

Methods

.. method:: adc.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:: adc.init()

   Enable the ADC block.

.. method:: adc.deinit()

   Disable the ADC block.

class ADCChannel --- read analog values from internal or external sources

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.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.