Skip to content

Instantly share code, notes, and snippets.

@HectorTorres
Created August 6, 2018 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HectorTorres/1d1e0b0e4bb962eaaf6c2bf34e63ed72 to your computer and use it in GitHub Desktop.
Save HectorTorres/1d1e0b0e4bb962eaaf6c2bf34e63ed72 to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include <Adafruit_MCP4725.h>
Adafruit_MCP4725 dac;
void setup(void) {
Serial.begin(9600);
Serial.println("Hello!");
// For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)
// For MCP4725A0 the address is 0x60 or 0x61
// For MCP4725A2 the address is 0x64 or 0x65
dac.begin(0x62);
Serial.println("Generating a triangle wave");
}
void loop(void) {
uint32_t counter;
// Run through the full 12-bit scale for a triangle wave
for (counter = 0; counter < 4095; counter++)
{
dac.setVoltage(counter, false);
}
for (counter = 4095; counter > 0; counter--)
{
dac.setVoltage(counter, false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment