"""P9-3 Generate a sawtooth waveform using MCP4725 on I2C Bus""" from machine import Pin, I2C i2c = I2C(1, scl = Pin(27), sda = Pin(26), freq = 400_000) DEV_ADDR = 0x60 i = 0 while True: # Create a bytearray of DAC command, high byte (D11-D4), low byte (D3-D0) ba = bytearray([0x40, (i >> 4) & 0xFF, (i << 4) & 0xF0]) # Write the bytearray to MCP4725 DAC through I2C i2c.writeto(DEV_ADDR, ba) i += 1 # Increment i