# analogWrite(DAC0, X), Analog voltage on DAC0 pin is higher for lower X value - is this normal?

I am using an Arduino DUE. Using the `analogWrite(DAC0, X)` command I am writing an analog value to this pin. X = 0 - 255 as I understand it.

I am observing that when X is lower, the voltage on DAC0 is higher nad when X is higher the voltage is lower.

Is that expected?

My code is simple:

``````void setup()
{
analogWriteResolution(12);
}

void loop()
{
analogWrite(DAC0, 10 );
}
``````
• `voltage is lower` ... how do you know what the output voltage is? ... you have not described how you are measuring the voltage. Feb 24 '18 at 6:20
• Using a DMM between the DAC0 pin and GND.
– Neil Dey
Feb 24 '18 at 6:27
• I don't understand. How else does one measure voltage?
– Neil Dey
Feb 24 '18 at 6:33
• @jsotola The load? I'm not sure what you are getting at. Feb 24 '18 at 6:59
• Look, comments under questions are for clarifying the question, not trying to answer them obliquely or not. If you want to ask under what load the measurement was made, then ask it. Feb 24 '18 at 7:01

That doesn’t sound right. Try setting x to 0 and measure with DC. You should get ~0.56 V. Repeat with 4095, and you should get ~2.76 V.

Also, note that with `analogWriteResolution(12)` your range is not 8-bits (0-255), but 12-bits (0-4095).

The output should follow:

Vout = Vref * Xin(2N-1) + Voffset

where

• Voffset = 0.56 V
• Vref = 2.2 V
• 0 ≤ Xin ≤ 4095
• According to the page about analogWrite: Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs. - so that shouldn't be an issue. Feb 24 '18 at 6:58
• @NickGammon Oops, that slipped passed me. I'll edit. Thanks Feb 24 '18 at 7:20