OpenMV also provides DAC on pin P6. We use DAC object, , to write digital value to analog value. For demo, we use a LED. We will control LED brightness by writing value digital 0-255. Analog output max is 3.3V.
Please connect LED to OpenMV on pin P6. Other pin is connected to GND. The following is my wiring.
Now you can open OpenMV IDE to write this program.
from pyb import Pin, DAC import time gpio_adc = 'P6' dac = DAC(gpio_adc) print('DAC demo') dac_val = 0 while 1: print('DAC: ' + str(dac_val)) dac.write(dac_val) dac_val = dac_val + 15 if dac_val>255: dac_val = 0 time.sleep(1000)
Save this program as dacdemo.py.
Run this program and see the program output on serial terminal.