Arduino with 12 bit DAC (MCP4725) Not Working I have an Arduino Mega AT2560 and need to have real DAC. I purchased the Sparkfun 12 bit DAC, however I don't think it is working properly.

I am using the Arduino wire library to communicate with the DAC. When I write 0, I am expecting to see 0v from the DAC's OUT pin. However, I see some seemingly random constant voltage. In reverse, when I write 4095 to the DAC I see the same voltage as when I write 0. I expected to see 5v.


Can someone verify that I hooked it up correctly?
Can someone verify the code I am using?




#include &lt;stdint.h&gt;
#include &lt;stdio.h&gt;
#include &lt;Wire.h&gt;

#define MCP4725_ADDR 0x60 // [0000 0110]
/*
* 12 Bit DAC MCP4725 gives a range of 4096 possible values.
* 
*/
void setup() {
  Wire.begin();
  Serial.begin(9600);
}

void loop() {
  Wire.beginTransmission(MCP4725_ADDR);
  Wire.write(64);            // cmd to update the DAC [0100 0000]
  Wire.write(4095 &gt;&gt; 4);        // the 8 most significant bits...
  Wire.write((4095 &amp; 15) &lt;&lt; 4); // the 4 least significant bits...
  Wire.endTransmission();
}
you want to make sure that there are pull-ups on the SCL/SDA lines;
you want to make sure that the address is correct. some routines use 7-bit notation for that, and others use 8-bit notation for that. end of the day, you want the transmission to be 0xc0 | (A2:A1:A0:R/W). so check the write.write() and see what it expects. I suspect that it expects 0xCx, rather than 0x6x.


having said that, here is your code running on an uno, with the dac configured as per sparkfun spec.



so I think it is fair to say that the code is ok but something happened on your end that prevented it from working.