user66858: I have an MKR WIFI1000 (v2.0 [Arduino:XYZ]) with a "real" analog output pin (DAC0/A0/PIN15). According to the documentation, this is a 10 bit DAC, so I assume I can write analogWrite(15, 1023) to have an output of 3.3V on that pin.
However, I don't seem to get it higher than 2.7V, which is already reached well before a value of 256.
This is my code:
#include <Arduino.h>

#define AN_OUTPUT 15

int counter = 0;

void setup()
{ 
  pinMode(AN_OUTPUT, OUTPUT);
}

void loop ()
{
  counter++;
  if (counter > 1023) {
    counter = 0;
  }

  analogWrite(AN_OUTPUT, counter);
  delayMicroseconds(1);
}

And this is the corresponding signal:


user66858: This link had the answer, you have to remove the pinMode(PIN, OUTPUT) line.

66858: <p>I have an MKR WIFI1000 (v2.0 [Arduino:XYZ]) with a &quot;real&quot; analog output pin (DAC0/A0/PIN15). According to the documentation, this is a 10 bit DAC, so I assume I can write <code>analogWrite(15, 1023)</code> to have an output of 3.3V on that pin.</p>
<p>However, I don't seem to get it higher than 2.7V, which is already reached well before a value of 256.</p>
<p>This is my code:</p>
<pre><code>#include &lt;Arduino.h&gt;

#define AN_OUTPUT 15

int counter = 0;

void setup()
{ 
  pinMode(AN_OUTPUT, OUTPUT);
}

void loop ()
{
  counter++;
  if (counter &gt; 1023) {
    counter = 0;
  }

  analogWrite(AN_OUTPUT, counter);
  delayMicroseconds(1);
}
</code></pre>
<p>And this is the corresponding signal:</p>
<p><a href="https://i.stack.imgur.com/qA4Ry.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qA4Ry.jpg" alt="enter image description here" /></a></p>
 66858: <p><a href="https://learn.adafruit.com/adafruit-feather-m0-basic-proto/adapting-sketches-to-m0" rel="nofollow noreferrer">This link</a> had the answer, you have to <strong>remove</strong> the <code>pinMode(PIN, OUTPUT)</code> line.</p>
