Audio Amplifier With the LM386!
by maker_soup in Circuits > Arduino
14103 Views, 28 Favorites, 0 Comments
Audio Amplifier With the LM386!
Hello everyone, today I'm going to show you how to make a simple audio amplifier with the very popular LM386. The hunt for an audio amplifier began when I wanted to spice up my Arduino projects with audio, but realized there was no easy method. This is how I was introduced to the LM386. The LM386 is capable of driving a vast array of speakers, and is very suitable for microcontrollers such as Arduino UNO or RaspberryPi.
Supplies
Designing the Circuit!
Time to design the circuit! I am using Easy EDA as it's the superior PCB design software; however, this circuit could be just as easily made in Eagle CAD or Fritzing. If you are using Easy EDA, which you should, add these parts to your build plate from the library:
- LM386N-4/NOPB
- RK1631110TT3
- (HDR-M-2.54_1x1) *5
- (SR211C104Kar) *3
- 1623925-3
- C441615
- C503219
- (GND connections) *7
After everything is added to the build plate re-name the parts by clicking on them and editing the name with the control panel on the right. Use the wire tool in the upper-right corner to connect all the parts as shown above. When you have finished connecting all of the nets save your work, so you can convert to PCB in the next step.
Designing the PCB!
To convert to PCB click "Design" in the toolbar at the top of your screen then "Convert to PCB". As everyone knows a nice PCB has round edges, so navigate to Tools>Set Board Outline where you will be presented with an array of outline customization options. With your cursor in the PCB build area click the "Track" button in the upper-right hand corner and connect the pins using the schematic as a guide. Don't connect the GND pins yet [This is a warning]. I would recommend a track width of 10mil for normal tracks and 78mil for input voltage tracks, e. pin 6 to Vs. After you have connected every net you should only have GND connections left; to connect them go to Place>Copper Area, make sure this is for GND, then put a border around your whole PCB and hit enter. Kablam! You are done designing your PCB! All that is left is to generate the gerber file for ordering. To generate the gerber click the button in the tool bar at the top that looks like a file with a "G" in it [why couldn't they just say gerber, it took me an hour to find this button.
Test the PCB!
We are going to test the PCB by playing some music from the Arduino! I have included a test file to upload onto the SD-card, but if you would like to choose your own music you will need to convert the .mp3 file to .wav format with this online converter. Make sure you have these settings selected: 8-bit, 16000Hz, and mono. Below are the connections for this circuit.
UNO----->>SD-card Module
5v--5v
GND--GND
13--CLK
12--DO
11--DI
10--CS
UNO----->>LM386
9--ARD
5v--VS
GND--GND
LM386----->>Speaker
S+--VIN
(S-)--GND
To upload the code to the Arduino make sure you have the correct board and port selected in "Tools". The only additional library needed for this code is the TMRpcm library, which can be downloaded from Tools>Manage Libraries.
All that is left is to upload the code to your Arduino and boogie down to some dank music.
//TMRpcm library is needed
#include <SD.h>
#define SD_ChipSelectPin 10
#include <TMRpcm.h>
#include <SPI.h>
TMRpcm tmrpcm;
void setup()
{
tmrpcm.speakerPin=9;
Serial.begin(9600);
if(!SD.begin(SD_ChipSelectPin))
{
Serial.println("SD fail");
return;
}
tmrpcm.setVolume(4);
tmrpcm.play("Imagine.wav");
}
void loop() {
// put your main code here, to run repeatedly:
}<br>
Downloads
Conclusion!
Congratulations! You have successfully just made an audio amplifier with the LM386! If you have any questions please comment them down below and I will try and get back to you within 1-2 days. God willing I will post a video about this project in the days to come as well as tutorials of my other projects!
For God so loved the world that He gave His one and only Son that whoever believes in Him shall not perish, but have everlasting life! - John 3:16
But He (Jesus) said to me, “My grace is sufficient for you, for my power is made perfect in weakness.” Therefore I will boast all the more gladly about my weaknesses, so that Christ’s power may rest on me. - 2 Corinthians 12:9 NIV
If you want to read an Instructable that has real value, check this out!