- Lesson 109-1: How to use MCP4725 DAC outping DC, Sine/Tringular wave using Arduino
- Lesson 109-2: Control the output voltage of MCP4725 from Serial Monito
- Lesson 109-3: Convert PWM duty cycle to Voltage using MCP4725 12bits DAC with Ardunino
- Lesson 109-4: Using Two MCP4725 DAC Module with Arduino
- Lesson 109-5: Controlling Speed of motor using Variable Resistor (potentiometer) and using Start/Stop push button with Arduino
Lesson 109: Generate DC Voltage using MCP4725 DAC with LCD and PWM to Voltage Converter with Arduino (5 projects)
Lesson 109: Generate DC Voltage using MCP4725 DAC with LCD and PWM to Voltage Converter with Arduino (5 projects)
Please select other codes for this lecture from the links below.
Related or required files and link to this lesson
- MCP4725 12 bits DAC Datasheet
- Purcahse this module from Amazon USA
- Purcahse this module from Amazon Canada
- Purcahse this module from All other Amazon
- Purcahse MCP4725 DAC from AliExpress
- Purcahse MCP4725 DAC from eBay
- Purcahse LCD1602 Display from Amazon USA
- Purcahse LCD1602 Display from Amazon Canada
- Purcahse LCD1602 Display from Banggood
- Purcahse LCD1602 Display from Amazon Europe
- Purcahse Multimeter used in This video from Amazon USA
- Purcahse Multimeter used in This video from Amazon USA
- Purcahse Multimeter used in This video from Amazon Canada
Part 14: Voltage and Current
In this lesson we learn how to use MCP4725 12 bits Digital To Analog Converter (DAC). The chip and module is explained, datasheet viewed and then using 5 Projects this MCP4725 practically shown. Full wiring diagram and wring shown and how to use the code and library explained.
In Project 4 in lesson 109 Lesson 109-4: Using Two MCP4725 DAC Module with Arduino
Projects
- Project 1: Output 0 to 5V or 0 to 3V depending on which kind of power sources you use for the module. The output shown on digital multimeter.
- Project 2: Serial command to set voltage
- Project 3: PWM duty cycle to Voltage converter
- Project 4: Using two MCP4725 DAC modules
- Project 5: Using Push button to set voltage on LCD
Timing of chapters in the video
00:00 Introduction1:19 MCP4725 Explained
4:46 Datasheet viewed
7:07 Project 1: Outputting DC Voltage
09:55 Code and library
13:00 Project 1: demonstration
17:34 Triangular wave
18:54 Sine wave
20:18 Project 2: Control voltage from Serial Monitor
22:21 Project 2: Demonstration
24:53 Project 3: Converting PWM to Voltage
27:33 Code Explained
29:25 Wiring explained
30:29 Project 3: Demonstration
33:25 Project 4: Using two MCP4725 modules
36:27 Project 4: Demonstration
37:30 Project 5: Setting output with push buttons on LCD
39:57 Code explained
45:53 Project 5: Demonstration
/*
* Lesson 109-4: Using Two MCP4725 DAC Module with Arduino
* each module can have independant different voltage source and
* can set to output independant voltage
*
* * Watch Video instrution for this code:https://youtu.be/j_BwZT9z-0g
Projects in this video: https://youtu.be/j_BwZT9z-0g
Project 1:Output 0 to 5V or 0 to 3V depending on which kind of power sources you use for the module. The output shown on digital multimeter.
Project 2 : Serial command to set voltage
Project 3: PWM duty cycle to Voltage converter
Project 4 (this project): Using two MCP4725 DAC modules
Project 5: Using Push button to set voltage on LCD
* Written by Ahmad Shamshiri using Adafruit library for MCP4725
Sep 26, 2022
www.Robojax.com
*
* This code is part of Arduino Step by Step Course which starts here: https://youtu.be/-6qSrDUA5a8
*
* for library of this code visit http://robojax.com/
*
If you found this tutorial helpful, please support me so I can continue creating
content like this. Make a donation using PayPal by credit card https://bit.ly/donate-robojax
* * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been download from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Based on the Adafruit MCP4725 Library
----> http://www.adafruit.com/products/935
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
*/
#include <Wire.h>
#include <Adafruit_MCP4725.h>
int refV1 = 4548;//set reference voltage for module 2 in mV
int refV2 = 3300;//set reference voltage for module 2 in mV
Adafruit_MCP4725 dac1;
Adafruit_MCP4725 dac2;
int mV1, mV2;//defining variable for millivot value for 1st and 2nd module
float V1, V2;//defining variable for volt value for 1st and 2nd module
void setup(void) {
Serial.begin(9600);
Serial.println("MCP4725 by Robojax");
//run i2C scanner to find out the I2C address and enter it below
//see video for details https://youtu.be/j_BwZT9z-0g
//get more code from www.Robojax.com
dac1.begin(0x60);//set I2C address for device dac1
dac2.begin(0x61);//set I2C address for device dac2
Serial.println("Dual MCP4725 Devices");
}
void loop(void) {
setmV2(1353);
Serial.print ("DAC1: ");
Serial.print(mV1);
Serial.println("mV");
delay(5000);
setV2(2.624);
Serial.print ("DAC2: ");
Serial.print(V2, 3);
Serial.println("V");
delay(5000);
Serial.println();
//see video for details https://youtu.be/j_BwZT9z-0g
//get more code from www.Robojax.com
}
/*
* setmV1()
* sets mV value such as 35mV or 2654mV (2.654V)
* Written Sep 25, 2022
* by Ahmad Shamshiri www.Robojax.com
*/
void setmV1(int d)
{
mV1 =d;
dac1.setVoltage(map(d, 0, refV1, 0, 4095), false);
}
/*
* setV1()
* sets Voltage value value in volts such as 3.764
* Written Sep 25, 2022
* by Ahmad Shamshiri www.Robojax.com
*/
void setV1(float d)
{
V1= d;
dac1.setVoltage( map((d *1000), 0, refV1, 0, 4095), false);
}
/*
* setmV2()
* sets mV value such as 35mV or 2654mV (2.654V)
* Written Sep 25, 2022
* by Ahmad Shamshiri www.Robojax.com
*/
void setmV2(int d)
{
mV2 =d;
dac2.setVoltage(map(d, 0, refV2, 0, 4095), false);
}
/*
* setV2()
* sets Voltage value value in volts such as 3.764
* Written Sep 25, 2022
* by Ahmad Shamshiri www.Robojax.com
*/
void setV2(float d)
{
V2= d;
dac2.setVoltage( map((d *1000), 0, refV2, 0, 4095), false);
}