How to Enable GPIO Audio Output on Raspberry Pi 3 - PWM

In this brief tutorial, I will explain how to enable GPIO PWM audio output on your Raspberry Pi 3.  The process is very easy and a beginner can do it.  All it is, is pasting the code below into your config.txt file.  There is no need to write scripts, solder and/or such nonsense.  Also below, you will see a video of how how it works, in action.  Yes, this will provide stereo sound through both channels.  I am using this with Retropie.

Paste the code below in to your config.txt file:
dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4

Step 1:  Login to your Pi:  User: pi    Password: raspberry

Step 2:  Open your config.txt file.
By command line or SSH type in: sudo nano /boot/config.txt



Step 3:  Paste in the code anywhere in the file.
dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4


Step 4:  Save the file.
Press ctrl+x to exit.  Press Y to save the file when prompted.

Step 5:  Reboot your Pi.
sudo reboot


Video showing that it works!



GPIO PINOUT from RPI Stack Exchange