Example explanation-02-read_adc read ADC

# 读取ADC例子
#
# 这个例子展示了如何使用ADC读取模拟引脚

import time
from pyb import ADC

adc = ADC("P6") # 必须是“P6”。

while(True):
    # ADC 12-bits 精度,4096个值
    print("ADC = %fv" % ((adc.read() * 3.3) / 4095))
    time.sleep_ms(100)

The pyb module cannot be used on OpenMV RT, only the following machine module can be used:

# 读取ADC例子
#
# 这个例子展示了如何使用ADC读取模拟引脚

import time
from machine import ADC

adc = ADC("P6")  # Must always be "P6".

while True:
    # ADC 16-bits 精度,65536个值
    print("ADC = %fv" % ((adc.read_u16() * 3.3) / 65535))
    time.sleep_ms(100)

pyb module adc.read() function documentation: Singtown Technology OpenMV official Chinese documentation function explanation:

results matching ""

    No results matching ""