openmv/scripts/examples/OpenMV/02-Board-Control/adc_read.py
iabdalkader 20587f308e Merge time and utime modules.
* Move clock class to utime module.
* Update all examples to be compatible with utime.
2020-11-27 15:44:39 +02:00

14 lines
305 B
Python

# ADC Read Example.
#
# This example shows how to use the ADC to read an analog pin.
import time
from pyb import ADC
adc = ADC("P6") # Must always be "P6".
while(True):
# The ADC has 12-bits of resolution for 4096 values.
print("ADC = %fv" % ((adc.read() * 3.3) / 4095))
time.sleep_ms(100)