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
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | 12-Bit DAC MCP4725 | A real analog output on I²C (0x60): dac.begin(0x60), dac.setVoltage(2048, false) → half of VCC on OUT. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno 5V | 12-Bit DAC MCP4725 VCC |
| 2 | Arduino Uno GND | 12-Bit DAC MCP4725 GND |
| 3 | Arduino Uno A4 | 12-Bit DAC MCP4725 SDA |
| 4 | Arduino Uno A5 | 12-Bit DAC MCP4725 SCL |
| 5 | Arduino Uno A0 | 12-Bit DAC MCP4725 OUT |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add a 12-bit DAC MCP4725 from the parts palette.
- Wire 1. Connect Arduino Uno 5V to 12-Bit DAC MCP4725 VCC.
- Wire 2. Connect Arduino Uno GND to 12-Bit DAC MCP4725 GND.
- Wire 3. Connect Arduino Uno A4 to 12-Bit DAC MCP4725 SDA.
- Wire 4. Connect Arduino Uno A5 to 12-Bit DAC MCP4725 SCL.
- Wire 5. Connect Arduino Uno A0 to 12-Bit DAC MCP4725 OUT.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- 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
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator