/* p9_1 Generate sawtooth waveform using DAC MCP4725 with Edubase-V2 board */ #include const char SLAVEADDR = 0x60; /* DAC MCP4725 address */ void setup() { Wire.begin(); /* initialize I2C */ } void loop() { static int i; i++; /* increment i */ /* write to MCP4725 DAC through I2C */ Wire.beginTransmission(SLAVEADDR); /* start talking to DAC */ Wire.write(0x40); /* send write DAC register command */ Wire.write(i >> 4) & 0xFF; /* send high byte data (D13-D4) */ Wire.write(i << 4) & 0xFF; /* send low byte data (D3-D0) */ Wire.endTransmission(); /* stop */ }