Книга: OpenMV Development Workshop
Назад: 5.3 Demo Analog Input (ADC): Working with Potentiometer
Дальше: 6. Working with I2C

5.4 Demo Analog Output (DAC)

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.

o5-9


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) 


o5-12

Save this program as dacdemo.py.

Run this program and see the program output on serial terminal.

o5-13


Назад: 5.3 Demo Analog Input (ADC): Working with Potentiometer
Дальше: 6. Working with I2C

Kirajes
Здесь можно Suninat 50mg (Сунитиниб) - Сунинат (Sunitinib) - аналог Сутент купить. Лекарство назначают больным, страдающим от онкологии желудка, кишечника, поджелудочной железы, полипов толстой кишки, новообразований в почке и прочих злокачественных опухолей, связанных с желудочно-кишечным трактом. сутент купить +в москве