user20002: I used my Arduino Uno's pin 3 to generate a PWM output. The code is:
void setup() {
  // Put your setup code here, to run once:
}

void loop() {
  analogWrite(3, 180);
}

I connected the output directly with a oscilloscope.
And the output waveform is shown below:

I found it's weird that the minimum voltage is negative! And with the duty cycle increasing, both the maximum voltage and minimum voltage decrease.
Why does it behave in such a way?

user20245: At first you had the scope AC (Alternating Current) coupled.  Then you switched it to DC (Direct Current) coupled.
AC coupling is used to remove the DC component of a signal.  It places a large capacitor between the probe and the internal amplifier.  This is used, for instance, if you want to see a small signal with a large DC offset.  But it can also attenuate and / or alter signals that are low in frequency.
When a PWM signal is AC coupled to an oscilloscope, an interesting phenomenon occurs.  As the duty cycle goes from a minimum (almost always off) to a maximum (almost always on) the DC component of the PWM signal changes.  Since the DC component is blocked by the AC coupling, the PWM signal appears to move lower on the screen as the duty cycle increases.
DC coupling is where there is no coupling capacitor between the probe and the internal amplifier.  Everything comes through.  For digital electronics where the signal travels a small distance from 0 to 5 volts or from 0 to 3.3 volts, this is the best way to use the scope.

20002: <p>I used my Arduino Uno's pin 3 to generate a <a href="http://en.wikipedia.org/wiki/Pulse-width_modulation" rel="nofollow noreferrer">PWM</a> output. The code is:</p>

<pre><code>void setup() {
  // Put your setup code here, to run once:
}

void loop() {
  analogWrite(3, 180);
}
</code></pre>

<p>I connected the output directly with a oscilloscope.
And the output waveform is shown below:</p>

<p><a href="https://i.stack.imgur.com/5tVdR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5tVdR.jpg" alt="PWM waveform"></a></p>

<p>I found it's weird that the minimum voltage is negative! And with the duty cycle increasing, both the maximum voltage and minimum voltage decrease.
Why does it behave in such a way?</p>
 20245: <p>At first you had the scope AC (Alternating Current) coupled.  Then you switched it to DC (Direct Current) coupled.</p>

<p>AC coupling is used to remove the DC component of a signal.  It places a large capacitor between the probe and the internal amplifier.  This is used, for instance, if you want to see a small signal with a large DC offset.  But it can also attenuate and / or alter signals that are low in frequency.</p>

<p>When a PWM signal is AC coupled to an oscilloscope, an interesting phenomenon occurs.  As the duty cycle goes from a minimum (almost always off) to a maximum (almost always on) the DC component of the PWM signal changes.  Since the DC component is blocked by the AC coupling, the PWM signal appears to move lower on the screen as the duty cycle increases.</p>

<p>DC coupling is where there is no coupling capacitor between the probe and the internal amplifier.  Everything comes through.  For digital electronics where the signal travels a small distance from 0 to 5 volts or from 0 to 3.3 volts, this is the best way to use the scope.</p>
