I want to use the DAC in a project but I am just not able to make it work correctly. The maximum output voltage of the DAC is somehow limited to 2.2V only. When running the DAC demonstration code from Seeed’s website I get the full voltage swing but when I run my sketch I only get up to 2.2V. The problem is that both the sketches are more or less the same.
I have tried running analogWrite() in a loop and with some delay before sampling but to no avail.
What am I missing?
My code is:
#include <Arduino.h>
void setup() {
SerialUSB.begin(9600);
while(!SerialUSB);
pinMode(A1, INPUT);
pinMode(A0, OUTPUT);
analogReadResolution(10);
analogWriteResolution(10);
while(1){
analogWrite(A0, pow((double) 2, 32) - 1);
delay(1000);
float y = analogRead(A1) * 3.3 / 1023L;
SerialUSB.print("DAC Output Voltage: ");
SerialUSB.println(y);
delay(1000);
}
}
void loop() {
// put your main code here, to run repeatedly:
}