Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Adafruit MCP4728: Examples, Pinouts, and Specs

Image of Adafruit MCP4728Design with Adafruit MCP4728 in Cirkit Designer

Introduction

The Adafruit MCP4728 is a versatile and precise multi-channel digital-to-analog converter (DAC) module. It is equipped with four independent 12-bit DAC channels, enabling the conversion of digital signals into analog voltages. This module is ideal for applications requiring multiple analog outputs, such as generating audio signals, controlling variable lighting, or driving analog sensors. It interfaces with microcontrollers via the I2C protocol, making it a convenient addition to projects that require analog capabilities but are limited to digital-only outputs.

Explore Projects Built with Adafruit MCP4728

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Battery-Powered Smart Light with Proximity Sensor and OLED Display using Adafruit QT Py RP2040: A project utilizing Adafruit MCP4728 in a practical application
Battery-Powered Smart Light with Proximity Sensor and OLED Display using Adafruit QT Py RP2040

This circuit is a portable, battery-powered system featuring an Adafruit QT Py RP2040 microcontroller that interfaces with an OLED display, a proximity sensor, an accelerometer, and an RGB LED strip. The system is powered by a lithium-ion battery with a step-up boost converter to provide 5V for the LED strip, and it includes a toggle switch for power control. The microcontroller communicates with the sensors and display via I2C.

Open Project in Cirkit Designer

Common Applications and Use Cases

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

Pin Number Pin Name Description
1 VDD Power supply (2.7V to 5.5V)
2 GND Ground
3 SCL I2C clock line
4 SDA I2C data line
5 A0 Address select bit 0 (I2C address pin)
6 A1 Address select bit 1 (I2C address pin)
7 A2 Address select bit 2 (I2C address pin)
8 VOUTA Analog output for DAC channel A
9 VOUTB Analog output for DAC channel B
10 VOUTC Analog output for DAC channel C
11 VOUTD Analog output for DAC channel D

Usage Instructions

How to Use the Component in a Circuit

  1. Connect the VDD pin to a power supply within the range of 2.7V to 5.5V.
  2. Connect the GND pin to the ground of your power supply.
  3. Connect the SCL and SDA pins to the I2C clock and data lines on your microcontroller.
  4. Set the A0, A1, and A2 pins according to the desired I2C address.
  5. Connect the VOUT pins (A, B, C, D) to your analog input devices.

Important Considerations and Best Practices

Example Code for Arduino UNO

#include <Wire.h>
#include <Adafruit_MCP4728.h>

Adafruit_MCP4728 mcp;

void setup() {
  Wire.begin(); // Start I2C bus
  mcp.begin(0x60); // Initialize MCP4728, default address 0x60

  // Set the voltage output of all channels to mid-scale
  mcp.setChannelValue(MCP4728_CHANNEL_A, 2048);
  mcp.setChannelValue(MCP4728_CHANNEL_B, 2048);
  mcp.setChannelValue(MCP4728_CHANNEL_C, 2048);
  mcp.setChannelValue(MCP4728_CHANNEL_D, 2048);
  mcp.saveToEEPROM(); // Save the current settings to EEPROM
}

void loop() {
  // Example: Cycle through voltage levels on channel A
  for (uint16_t i = 0; i < 4096; i++) {
    mcp.setChannelValue(MCP4728_CHANNEL_A, i);
    delay(10);
  }
}

Troubleshooting and FAQs

Common Issues

Solutions and Tips for Troubleshooting

FAQs

Q: Can I use the MCP4728 with a 3.3V system? A: Yes, the MCP4728 can operate at voltages as low as 2.7V.

Q: How do I change the I2C address of the MCP4728? A: The I2C address can be changed by adjusting the A0, A1, and A2 pins.

Q: Can I save the DAC output values so they persist after power cycling? A: Yes, the saveToEEPROM() function will store the current DAC values to the internal EEPROM.

Q: Is it possible to update all DAC channels simultaneously? A: Yes, the MCP4728 supports a multi-write command to update all channels at once.