一、MCP4725介绍
MCP4725是一款12位的,能够输出1-5V指定电压的DAC芯片,通信方式是使用IIC通信。
二、实物展示
15块买的12位DAC
添加库文件
DFROBOT这个
代码和例程差不多
#include <Arduino.h>
#include <Wire.h>
#include "DFRobot_MCP4725.h"
//MCP4725模块与ESP32连接 nodemcu32s硬件IIC sda-->21 scl-->22
#define REF_VOLTAGE 3300
DFRobot_MCP4725 DAC;
uint16_t OUTPUT_VOLTAGE = 3300;
void setup(void)
{
Wire.begin();
Serial.begin(115200);
DAC.init(MCP4725A0_IIC_Address0, REF_VOLTAGE);
}
void loop(void)
{
Serial.print("DFRobot_MCP4725 output: ");
Serial.print(OUTPUT_VOLTAGE);
Serial.println(" mV");
DAC.outputVoltage(OUTPUT_VOLTAGE);
delay(200);
}