user65410: I am using arduino Uno/Mega.
I am trying to output a range of 0-5v volts using PWM.
Is it possible to do it?
It’s would be nice to see some code or instructions, as far I have seen, they used external Module to get that voltage range, maybe I am wrong or I didn’t understand them well.
Thanks!

user50238: The Arduino is a digital device; each output pin is either HIGH (+5v) or LOW (0v = GND), not in between.
For certain types of devices (motors, LEDs) there is a technique you mentioned called PWM, pulse width modulation, which turns the output on and off rapidly. It's still just a square wave alternating between 0 and 5v but it's doing it really fast. So for an LED for example, your eye will make you think it's at half-brightness even though it is flashing on and off very quickly.
To do this you need to use a pin that has "analog" ability and use the "analogWrite" command.

user2967: Short answer: No.
Arduino Unos and Megas have PWM (Pulse Width Modulation) output, which rapidly turn the output on and off with a varying "duty cycle" (The ratio of on time to off time.) That is not the same thing as an analog output voltage.
If you have a constant load you can build a low pass filter that will smooth the output to a slightly dirty DC output based on the PWM output.
You're better off using an external DAC (Digital to Analog Converter.) You send that a digital value and it converts it to a clean, filtered analog output. Most modern DACs are fast enough to output complex waveforms like music.
Edit:
The Arduino zero apparently has a built-in DAC with up to 10-bit resolution. you could use that to output a low current DC voltage. However the zero is a 3.3V device.

65410: <p>I am using arduino Uno/Mega.</p>
<p>I am trying to output a range of 0-5v volts using PWM.</p>
<p>Is it possible to do it?</p>
<p>It’s would be nice to see some code or instructions, as far I have seen, they used external Module to get that voltage range, maybe I am wrong or I didn’t understand them well.</p>
<p>Thanks!</p>
 50238: <p>The Arduino is a digital device; each output pin is either HIGH (+5v) or LOW (0v = GND), not in between.</p>
<p>For certain types of devices (motors, LEDs) there is a technique you mentioned called PWM, pulse width modulation, which turns the output on and off rapidly. It's still just a square wave alternating between 0 and 5v but it's doing it really fast. So for an LED for example, your eye will make you think it's at half-brightness even though it is flashing on and off very quickly.</p>
<p>To do this you need to use a pin that has &quot;analog&quot; ability and use the &quot;analogWrite&quot; command.</p>
 2967: <p>Short answer: No.</p>
<p>Arduino Unos and Megas have PWM (Pulse Width Modulation) output, which rapidly turn the output on and off with a varying &quot;duty cycle&quot; (The ratio of on time to off time.) That is not the same thing as an analog output voltage.</p>
<p>If you have a constant load you can build a low pass filter that will smooth the output to a slightly dirty DC output based on the PWM output.</p>
<p>You're better off using an external DAC (Digital to Analog Converter.) You send that a digital value and it converts it to a clean, filtered analog output. Most modern DACs are fast enough to output complex waveforms like music.</p>
<h2>Edit:</h2>
<p>The Arduino zero apparently has a built-in DAC with up to 10-bit resolution. you could use that to output a low current DC voltage. However the zero is a 3.3V device.</p>
