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 <stdint.h>
#include <stdio.h>
#include <Wire.h>
#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 >> 4); // the 8 most significant bits...
Wire.write((4095 & 15) << 4); // the 4 least significant bits...
Wire.endTransmission();
}