How to Use MCP4725 12 Bit Digital to Analog Converter Using Arduino
by RonFrtek in Circuits > Arduino
201 Views, 1 Favorites, 0 Comments
How to Use MCP4725 12 Bit Digital to Analog Converter Using Arduino
In this tutorial we will learn how to use MCP4725 12Bit Digital to Analog Converter with Arduino and Visuino to generate Square, Sine and Triangle waves.
Watch the Video!
What You Will Need
- Arduino UNO or ESP32 (Or any other Board)
- MCP4725 module
- To do the test experiment:
- 1k ohm resistor
- LED
- Jumper wires
- Breadboard
- Oscilloscope (Optional)
- Visuino program: Download Visuino
Brought by PCBWay
Thank you PCBWay for supporting this tutorial and helping users learn more about electronics.
NEW! Now you can get Aluminum PCB & FLEX PCB in their Special Offer!
What I like about the PCBWay is that you can get 10 boards for approximately $5 which is really cost effective for professional made boards, not to mention how much time you save!
Go check them out here. They also offer a lot of other stuff in case you might need it like assembly, 3D printing, CNC machining and a lot more.
The Circuit
- Connect Arduino pin [5V] to breadboard positive pin [Red line]
- Connect Arduino pin [GND] to breadboard negative pin [Black line]
- Connect MCP4725 pin [Out] to 1K ohm Resistor on the breadboard
- Connect other side of the Resistor to the LED pin [positive +]
- Connect LED pin [negative - ] to the breadboard negative pin [Black line]
- Connect MCP4725 pin [SCL] to Arduino pin [SCL]
- Connect MCP4725 pin [SDA] to Arduino pin [SDA]
- Connect MCP4725 pin [VCC] to breadboard positive pin [Red line]
- Connect MCP4725 pin [GND] to breadboard positive pin [Black line]
- Connect Oscilloscope Signal probe to MCP4725 pin [Out]
- Connect Oscilloscope Ground probe to breadboard positive pin [Black line]
Start Visuino, and Select the Arduino UNO Board Type
Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2
Generate Square Waves - in Visuino Add & Set Components
- Add "Microchip I2C Digital To Analog Converter (DAC) - MCP4725" component
- Add "Square Analog Generator" component
- Connect "SquareAnalogGenerator1" pin [Out] to "DAC1" pin [In]
- Connect "DAC1" pin I2C [Out] to the Arduino Board pin I2C [In]
- Upload the Project to the Board, see the "Generate, Compile, and Upload the Arduino Code" Step on how to upload the project
Generate Sine Waves - in Visuino Add & Set Components
- Add "Microchip I2C Digital To Analog Converter (DAC) - MCP4725" component
- Add "Sine Analog Generator" component
- Set the "Frequency" in the Properties window to 0.2
- Connect "SineAnalogGenerator1" pin [Out] to "DAC1" pin [In]
- Connect "DAC1" pin I2C [Out] to the Arduino Board pin I2C [In]
- Upload the Project to the Board, see the "Generate, Compile, and Upload the Arduino Code" Step on how to upload the project
Generate Triangle Waves - in Visuino Add & Set Components
- Add "Microchip I2C Digital To Analog Converter (DAC) - MCP4725" component
- Add "Triangle Analog Generator" component
- [Optional] Set the "Frequency" in the Properties window
- Connect "TriangleAnalogGenerator1" pin [Out] to "DAC1" pin [In]
- Connect "DAC1" pin I2C [Out] to the Arduino Board pin I2C [In]
- Upload the Project to the Board, see the "Generate, Compile, and Upload the Arduino Code" Step on how to upload the project
Generate Digital Pulses - in Visuino Add & Set Components
- In this Example we are going to convert digital pulses from "Pulse Generator" component to Analog Signal using a "Digital To Analog" component
- Add "Microchip I2C Digital To Analog Converter (DAC) - MCP4725" component
- Add "Pulse Generator" component
- [Optional] Set the "Frequency" in the Properties window
- Add "Digital To Analog" component
- [Optional] Set the "True" or "False" values in the Properties window
- Connect "PulseGenerator1" pin [Out] to "DigitalToAnalog1" pin [In]
- Connect "DigitalToAnalog1" pin [Out] to "DAC1" pin [In]
- Connect "DAC1" pin I2C [Out] to the Arduino Board pin I2C [In]
- Upload the Project to the Board, see the "Generate, Compile, and Upload the Arduino Code" Step on how to upload the project
Generate, Compile, and Upload the Arduino Code
In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.
Play
If you power the Board LED will Blink and if you are using an oscilloscope you should see the signal from the MCP4725 module. There are many ways to use this module this was just a quick simple introduction to get started.
Note: In my Project I set the I2C Address of the "Microchip I2C Digital To Analog Converter (DAC) - MCP4725" to 96, you should check the address of your module.
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu