mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add new DAC example.
This commit is contained in:
parent
42af0273e1
commit
4ff6e6285c
15
scripts/examples/02-Board-Control/dac_write_timed.py
Normal file
15
scripts/examples/02-Board-Control/dac_write_timed.py
Normal file
@ -0,0 +1,15 @@
|
||||
# DAC Timed Write Example
|
||||
#
|
||||
# This example shows how to use the DAC pin output onboard your OpenMV Cam.
|
||||
|
||||
import math
|
||||
from pyb import DAC
|
||||
|
||||
# create a buffer containing a sine-wave
|
||||
buf = bytearray(100)
|
||||
for i in range(len(buf)):
|
||||
buf[i] = 128 + int(127 * math.sin(2 * math.pi * i / len(buf)))
|
||||
|
||||
# output the sine-wave at 400Hz
|
||||
dac = DAC("P6")
|
||||
dac.write_timed(buf, 400 * len(buf), mode=DAC.CIRCULAR)
|
||||
Loading…
Reference in New Issue
Block a user