Simple test
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""Simple demo of writing a sine wave to the AD569x DAC."""
5
6import math
7import board
8import busio
9import adafruit_ad569x
10
11i2c = busio.I2C(board.SCL, board.SDA, frequency=400_000)
12
13# Initialize AD569x
14dac = adafruit_ad569x.Adafruit_AD569x(i2c)
15
16# length of the sine wave
17LENGTH = 100
18# sine wave values written to the DAC
19value = [
20 int(math.sin(math.pi * 2 * i / LENGTH) * ((2**15) - 1) + 2**15)
21 for i in range(LENGTH)
22]
23
24while True:
25 for v in value:
26 dac.value = v