dac_write_timed.py
# Ce travail est publié sous licence MIT.
# Copyright (c) 2013-2023 OpenMV LLC. Tous droits réservés.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Exemple d'écriture temporisée DAC
#
# Cet exemple montre comment utiliser la sortie de la broche DAC embarquée sur votre OpenMV Cam.
import math
from pyb import DAC
# créer un tampon contenant une onde sinusoïdale
buf = bytearray(100)
for i in range(len(buf)):
buf[i] = 128 + int(127 * math.sin(2 * math.pi * i / len(buf)))
# générer l'onde sinusoïdale à 400 Hz
dac = DAC("P6")
dac.write_timed(buf, 400 * len(buf), mode=DAC.CIRCULAR)