Back to Arduino Step By Step Course
If you don't like to see ads while video is being played you can purchase this course for $200 from Udemy or purchase YouTube premium Here
Please select other codes for this lecture from the links below.
Please download required files for this code
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 1 in lesson 109 Using MCP4725 12bits DAC with Ardunino
/*
* Lesson 109-1: Generates output DC Voltage from 0 to 5.5V or lower. if power supply
* is 3.3V, then max voltage is 3.3V.
* you can use it simply to enter your request as millivolt like 365mV
* or 2.872V
*
* * Watch Video instrution for this code:https://youtu.be/j_BwZT9z-0g
Projects in this video: https://youtu.be/j_BwZT9z-0g
Project 1 (this project):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
* 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 refV = 4530;//reference voltage. see video for details
Adafruit_MCP4725 dac;
int mV;
float V;
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
dac.begin(0x60);
Serial.println("Output Voltage");
}
void loop(void) {
// setmV(465);//set output to 465mV
// Serial.print(mV);
// Serial.println("mV");
// delay(5000);
//
// setV(2.635);//set output to 2.6V
// Serial.print(V, 3);
// Serial.println("V");
// delay(5000);
// Serial.println();
for(int i=0; i<refV; i +=100)
{
setmV(i);
Serial.println(i);
}
//see video for details https://youtu.be/j_BwZT9z-0g
//get more code from www.Robojax.com
}
/*
* setmV()
* sets mV value such as 35mV or 2654mV (2.654V)
* Written Sep 25, 2022
* by Ahmad Shamshiri www.Robojax.com
*/
void setmV(int d)
{
mV =d;
dac.setVoltage(map(d, 0, refV, 0, 4095), false);
}
/*
* setV()
* sets Voltage value value in volts such as 3.764
* Written Sep 25, 2022
* by Ahmad Shamshiri www.Robojax.com
*/
void setV(float d)
{
V = d;
dac.setVoltage( map((d *1000), 0, refV, 0, 4095), false);
}
The least I expect from you is to thumb up the video and subscribe to my channel. I appriciate that. .I have spent months making these lectures and writing code. You don't lose anything by subscribging to my channel. Your subscription is stamp of approval to my videos and more people can find them and in it turn it helps me. Thank you
If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal
**** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.