Example: 50-OpenMV-Boards/52-Alif-Boards/50-Board-Control/adc.py
# 本作品采用MIT许可证授权。
# Copyright (c) 2013-2026 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# ADC读取示例。
#
# 此示例展示了如何使用ADC读取模拟引脚。
# P8 and P9 are the only ADC-capable I/O pins on the OpenMV AE3.
# These pins are 1.8V tolerant (not 3.3V like the other I/O pins).
import time
from machine import ADC
adc = ADC("P8") # Must be "P8" or "P9" on the OpenMV AE3.
while True:
# ADC具有16位分辨率,可输出65536个数值。
print("ADC = %fv" % ((adc.read_u16() * 1.8) / 65535))
time.sleep_ms(100)