Simple test

Ensure your device works with this simple test.

examples/ad569x_simpletest.py
 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
 7
 8import board
 9import busio
10
11import adafruit_ad569x
12
13i2c = busio.I2C(board.SCL, board.SDA, frequency=400_000)
14
15# Initialize AD569x
16dac = adafruit_ad569x.Adafruit_AD569x(i2c)
17
18# length of the sine wave
19LENGTH = 100
20# sine wave values written to the DAC
21value = [int(math.sin(math.pi * 2 * i / LENGTH) * ((2**15) - 1) + 2**15) for i in range(LENGTH)]
22
23while True:
24    for v in value:
25        dac.value = v