openmv/scripts/examples/50-OpenMV-Boards/50-IMXRT-Boards/50-Board-Control/adc.py
2024-02-16 12:01:32 -08:00

18 lines
478 B
Python

# This work is licensed under the MIT license.
# Copyright (c) 2013-2024 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# ADC Read Example.
#
# This example shows how to use the ADC to read an analog pin.
import time
from machine import ADC
adc = ADC("P6") # Must always be "P6".
while True:
# The ADC has 16-bits of resolution for 65536 values.
print("ADC = %fv" % ((adc.read_u16() * 3.3) / 65535))
time.sleep_ms(100)