#include<Wire.h> //Include Wire library for using I2C functions
#define MCP4725 0x60 //MCP4725 address as 0x61 Change yours accordingly
unsigned long adc;
byte buffer[3];
void setup()
{
Wire.begin(); //Begins the I2C communication
}
void loop()
{
buffer[0] = 0b01000000; //Sets the buffer0 with control byte (010-Sets in Write mode)
adc = analogRead(A0) * 4; //Read Analog value from pin A0 and convert into digital (0-1023) multiply with 4 gives (0-4096)
unsigned long ipvolt = (5.0/4096.0)* adc; //Finding voltage formula (A0)
buffer[1] = adc >> 4; //Puts the most significant bit values
buffer[2] = adc << 4; //Puts the Least significant bit values
unsigned long analogread = analogRead(A1)*4 ; //Reads analog voltage from A1
unsigned long opvolt = (5.0/4096.0)* analogread; //Finding Voltage Formula (A1)
Wire.beginTransmission(MCP4725); //Joins I2C bus with MCP4725 with 0x61 address
Wire.write(buffer[0]); //Sends the control byte to I2C
Wire.write(buffer[1]); //Sends the MSB to I2C
Wire.write(buffer[2]); //Sends the LSB to I2C
Wire.endTransmission(); //Ends the transmission
delay(2500);} [code]
ardunio unodan mcp 4725 gercek anolog cıkış
eklemiş oldum mcp4725 kodlar anolog gırış potansiyometreden gelen voltajı 0 5 v arası 4096 bölerek cıkışa aktarıyor ve calısıyor cıkış 0 ...5v cıkıyor
normalde bu kodları atmega 328 yaptırmak kolay ( map ) komutunda map. 0 1023,, (255,,,0 ) bit ceviriyor cıkıs hem pwm hem 8 bit yetersıs gercek anolog cıkış alabilecegim arklı ceviricilerde olabilir 12bit ve üstü 16 mukemmel olurdu yok
fakat ben cıkışı 5v dan 0v geriye dogru ölcmesıni cıkıs almak istiyorum bir türlü beceremedim yardımcı olurmusunuz