Easy-Python  1.00.00Change to: 中文
adc

Functions

 ADC (adc_channel)
 Make new ADC object. More...
 
 init ()
 Turn on the ADC channel. More...
 
 deinit ()
 Turn off the ADC channel. More...
 
 channel (adc_channel)
 Switch adc channel before read(). More...
 
 read ()
 Get ADC current value. More...
 

Detailed Description

The adc object get data form adc with 10 bit.

KEY Example of Micropython
Click here
Example Code of usage:
from machine import ADC
tmp = ADC(0)
tmp.init(1)
tmp.init(2)
tmp.channel(0)
adc_buff=0
for y in range(0,9):
adc_buff = tmp.read()
print(adc_buff)
tmp.channel(1)
adc_buff=0
for y in range(0,9):
adc_buff = tmp.read()
print(adc_buff)

Function Documentation

ADC ( adc_channel  )

Make new ADC object.

Create an ADC object associated with the given ADC:

Parameters
[in]adc_channel: the adc_channel number 0~5
Returns
(object)
Example of usage:
from machine import ADC
tmp = ADC(0)
init ( )

Turn on the ADC channel.

Parameters
[in]adc_channel: 0~5
Returns
(object)
Example of usage:
from machine import ADC
tmp = ADC(0)
tmp.init(1) # initialize channel 1.
deinit ( )

Turn off the ADC channel.

Parameters
no
Returns
(no)
Example of usage:
from machine import ADC
tmp = ADC(0)
tmp.deinit()
channel ( adc_channel  )

Switch adc channel before read().

ADC.channel(adc_channel)

Parameters
[in]adc_channel: 0~5
Returns
(a byte)
Example of usage:
from machine import ADC
tmp = ADC(0)
tmp.init(1)
tmp.init(2)
tmp.channel(0) # Switch adc channel
adc_buff = tmp.read() # get adc data for channel 0.
read ( )

Get ADC current value.

ADC.read()

Parameters
no
Returns
(a byte)
Example of usage:
from machine import ADC
tmp = ADC(0)
adc_buff=0
adc_buff = tmp.read()