Using TC1321 10bits DAC I2C

Here I leave one example how to generate a 0-2.5V (depens on your Vref) ramp with the TC1321.


#include <Wire.h>

byte i2cAddr=B1001000;//device ID Address for my TC1321

void setup()

void loop(){

for (int i=0; i<1024; i++){
transmite (i2cAddr, 0x00, i);
delay(10); // up to you


void transmite(byte x,byte y, int i) // dirección, registro, valor
int b=i<<6; // 2 bytes splitted: b9-b2 first, and b1-b0 secondly (regarding 10 bits of i)
byte c=b;
Wire.write(y); //select register
Wire.write(i>>2); //set value b9-b2
Wire.write(c); //set value b1-b0 on cb7 and cb6