Arduino MCP4725 DAC: Wiring, Code and Simulator

To build this Arduino MCP4725 DAC project you need an Arduino Uno and a 12-bit DAC MCP4725. A 12-bit DAC makes real voltages; the Uno reads them back on A0. Make the 5 connections in the wiring table, upload the Arduino C++ code, and step the code by 256 instead to draw a staircase on the plotter.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
112-Bit DAC MCP4725A real analog output on I²C (0x60): dac.begin(0x60), dac.setVoltage(2048, false) → half of VCC on OUT.

Wiring

#FromTo
1Arduino Uno 5V12-Bit DAC MCP4725 VCC
2Arduino Uno GND12-Bit DAC MCP4725 GND
3Arduino Uno A412-Bit DAC MCP4725 SDA
4Arduino Uno A512-Bit DAC MCP4725 SCL
5Arduino Uno A012-Bit DAC MCP4725 OUT

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a 12-bit DAC MCP4725 from the parts palette.
  3. Wire 1. Connect Arduino Uno 5V to 12-Bit DAC MCP4725 VCC.
  4. Wire 2. Connect Arduino Uno GND to 12-Bit DAC MCP4725 GND.
  5. Wire 3. Connect Arduino Uno A4 to 12-Bit DAC MCP4725 SDA.
  6. Wire 4. Connect Arduino Uno A5 to 12-Bit DAC MCP4725 SCL.
  7. Wire 5. Connect Arduino Uno A0 to 12-Bit DAC MCP4725 OUT.
  8. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  9. Run it. Press Run. Step the code by 256 instead to draw a staircase on the plotter.

Arduino C++ code

// Adafruit MCP4725: a 12-bit DAC. Its output is read back on the Uno's A0.
#include <Adafruit_MCP4725.h>

Adafruit_MCP4725 dac;

void setup() {
  Serial.begin(9600);
  dac.begin(0x60);
}

void loop() {
  for (uint16_t code = 1024; code <= 3072; code += 1024) {
    dac.setVoltage(code, false);
    delay(50);
    Serial.print("DAC ");
    Serial.print(code);
    Serial.print(" -> A0 ");
    Serial.println(analogRead(A0));
    delay(200);
  }
}

What to try

Step the code by 256 instead to draw a staircase on the plotter.

Frequently asked questions

How do I wire the MCP4725 DAC project on an Arduino Uno?

Make 5 connections: Arduino Uno 5V to 12-Bit DAC MCP4725 VCC; Arduino Uno GND to 12-Bit DAC MCP4725 GND; Arduino Uno A4 to 12-Bit DAC MCP4725 SDA; Arduino Uno A5 to 12-Bit DAC MCP4725 SCL; Arduino Uno A0 to 12-Bit DAC MCP4725 OUT.

What parts do I need for this Arduino project?

An Arduino Uno and a 12-bit DAC MCP4725.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

A 12-bit DAC makes real voltages; the Uno reads them back on A0.

More Arduino Uno projects