Next up, download the Adafruit MCP4725 library. This library does all of the interfacing, so you can just "set and forget" the DAC output. It also has some examples to get you started
The library is available on GitHub. You can download it by clicking the button below.
Rename the uncompressed folder Adafruit_MCP4725. Check that the Adafruit_MCP4725 folder contains Adafruit_MCP4725.cpp and Adafruit_MCP4725.h
Place the Adafruit_MCP4725 library folder your sketchbookfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. You can figure out your sketchbookfolder by opening up the Preferences tab in the Arduino IDE.
Restart the IDE.
Open up the File→Examples→Adafruit_MCP4725→trianglewave sketch and upload it to the Arduino. Then connect your oscilloscope (or an LED + resistor if you don't have access to an oscilloscope)
First, be sure to call begin(addr) where addr is the i2c address (default is 0x62, if A0 is connected to VCC its 0x63). Then call setVoltage(value, storeflag) to set the DAC output. value should range from 0 to 0x0FFF. storeflag indicates to the DAC whether it should store the value in EEPROM so that next time it starts, it'll have that same value output. You shouldn't set the flag to true unless you require it as it will take longer to do, and you could wear out the EEPROM if you write it over 20,000 times.
TWBR = 12; // 400 khzYou can speed this up a bit more, if you'd like, check the ATmega328 datasheet for how to calculate the TWBR register.