Simple Arduino Audio Player and Amplifier with LM386

Arduino

ByAswinth Raj 101

Simple Arduino Audio Player and Amplifier with LM386

Adding sounds or music to our project will always make it looks cool and sounds much more attractive. Especially if you are using an Arduino and you have lots of pins free, you can easily add sound effects to your project by just investing in an extra SD card module and a normal speaker. In this article I will show you how easy it is to Play music/add sound effects using your Arduino Board.  Thanks to the Arduino community who have developed some libraries to build this in a fast and easy way. We have also used IC LM386 here for amplification and noise cancelation purpose.

 

Hardware Required:

  1. Arduino UNO
  2. SD Card Reader module
  3. SD card
  4. LM386 Audio Amplifier
  5. 10uf Capacitor (2 Nos)
  6. 100uf Capacitor (2 Nos)
  7. 1K,10K Resistor
  8. Push buttons (2 Nos)
  9. Breadboard
  10. Connecting Wires

 

Getting ready with your WAV audio files:

For playing sounds from SD Card using Arduino, we need audio files in .wav format because Arduino Board can play an audio file in a specific format that is wav format. To make an arduino mp3 player, there are a lot of mp3 shields are available which you can use with arduino. Or else to play mp3 files in arduino, there are websites which you can be used to convert any audio file on your computer into that specific WAV file.

 

So to convert any audio file into wav format, follow the below steps:

 

Step 1: Click on “Online Wav Converter” to enter into the website.

 

Step 2: Arduino can play a wav file in the following format. You can toy around with the settings later, but these settings were experiment to be the best in quality.

 

Bit Resolution

8 Bit

Sampling Rate

16000 Hz

Audio Channel

Mono

PCM format

PCM unsigned 8-bit

 

Step 3: In the website click on “choose file” and select the file you want to convert. Then feed in the above settings. Once done it should look something like this in the below image

converting audio files into wav format for playing using Arduino

 

Step 4:  Now, click on “Convert File” and your Audio file will be converter to .Wav file format. It will also be downloaded once the conversion is done.

 

Step 5: Finally format your SD card and save your .wav audio file into it. Make sure you format it before you add this file. Also remember the name of your audio file. Similarly you can select any of your four audios and save them with names 1, 2, 3 and 4(Names should not be changed). I have converted four songs and have saved them as 1.wav, 2.wav, 3.wav and 4.wav like shown below.

songs in wav format for playing using Arduino

 

Circuit and Hardware:

Circuit Diagram for this Arduino Audio File Player is simple. The complete circuit diagram is shown in the Image below.

Simple Arduino Audio Player with LM386 amplifier circuit diagram

As we know our audio files are saved into the SD card, hence we interface a SD card reader module with our Arduino. The Arduino and SD card communicate using the SPI communication protocol. Hence the Module is interfaced with the SPI pins of the Arduino as shown above in the diagram. It is further listed in the table below.

Arduino

SD card module

+5V

Vcc

Gnd

Gnd

Pin 12

MISO (Master In Slave out)

Pin 11

MOSI (Master Out Slave In)

Pin 13

SCK (Synchronous Clock)

Pin 4

CS (Chip Select)

 

Now the Arduino will be able to read the music file from the SD card and play it on the pin number 9. But the audio signals produced by the Arduino on pin 9 will not be audible much. Hence we amplify it by using the LM386 Low voltage Audio amplifier IC.

The amplifier shown above is designed for a Gain of 200 and the Vdd (pin 6) is powered by the 5V pin of the Arduino. If you want to increase/decrease the sound you can increase/decrease the voltage provided to this pin. It can withstand a maximum of 15V. Learn more about this 200 gain amplification configuration for LM386 here.

We also have two push buttons connected to the pin 2 and 3 of the Arduino. These switches are used to play the next track of the song and play/pause the music respectively. I have used these buttons just to demonstrate its abilities; you can play the song whenever required. Check the Demo Video at the end.

 

You can assemble this circuit completely over a Breadboard as shown in the picture below

Simple Arduino music Player fritzing breadboard image

 

Programming your Arduino:

Once we are ready with the Hardware and the SD card, we are just one step away playing those songs. Insert the card into your SD card module and follow the steps below.

Step 1: As said earlier we will be using a library to make this project work. The link for the library is given below. Click on it and select “Clone or download” and choose download as ZIP.

 

Step 2: Add this Zip file into your Arduino IDE by selecting Sketch->Include Library -> Add .ZIP Library as shown below and select the ZIP file that we just downloaded.

installing library for playing audio files using Arduino

 

Step 3: The complete program of the arduino music player project is given at the end of this article, simply copy it and paste it in the Arduino Program. Now, click on Upload and get ready to play your audio files.

 

The program is self explanatory since they have the comment lines. But, I have also explained the ability of the TMRpcm library below.

 

Playing an audio file:

You can play any audio that is stored in Wav format inside the SD card module by using the line below.

music.play("3.wav");
//object name.play (“FileName.wav”);

You can use this line at places where you want to trigger the Audio

 

Pause an audio File:

To pause an Audio file, you can simply call the line below.

music.pause();
//objectname.pause();

 

Forwarding/Rewinding an Audio: 

There are not direct ways to forward or rewind an Audio file, but you can use the line below to play a song at a particular time. This can be used to forward/rewind with some additional programming.

music.play("2.wav",33); //Plays the song from 33rd second
//objectname.play(“Filename.wav”,time in second);

 

Setting the quality of the audio:

The library gives us two qualities to play the music, one is to play as normal mode the other to play with 2X oversampling.

music.quality(0); //Normal Mode
music.quality(1); //2X over sampling mode

 

Setting the Volume of the audio:

Yes, you can control the volume of the audio through software. You can simply set the volume by using the line below. Higher music volumes tend to affect the quality of the audio, hence use hardware control when possible.

music.setVolume(5);        //Plays the song at volume 5
//objectname.setVolume(Volume level);

 

Working of this Arduino Music Player:

After programming your Arduino simply press the button connected to pin 2 and your Arduino will play the first song (saved as 1.wav) for you.  Now you can press the button again to change your track to the next song that is to play 2.wav. Likewise you can navigate to all four songs.

You can also play/Pause the song by pressing the button connected to pin 3. Press it once to pause the song and press it again to play it from where it stopped.  Watch the video below for complete working (or maybe to relax yourself with some songs).

playing songs from SD card using Arduino

Hope you enjoyed the project. Now it is up to your creativity to use them in your projects. You can make a speaking clock, voice assistant, talking robot, voice alert security system and much more. Let me know how you are planning to use it through the comment section and also if you have any problems in getting this thing work you can reach me through the forums or the comment section below.

Code

/*
Arduino Based Music Player

 This example shows how to play three songs from SD card by pressing a push button

 The circuit:
 * Push Button on pin 2 and 3
 * Audio Out - pin 9
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4 

 created  25 Jun 2017
 by Aswinth Raj

 This example code was created for CircuitDigest.com

 */
 
#include "SD.h" //Lib to read SD card
#include "TMRpcm.h" //Lib to play auido
#include "SPI.h" //SPI lib for SD card

#define SD_ChipSelectPin 4 //Chip select is pin number 4
TMRpcm music; //Lib object is named "music"

int song_number=0;
boolean debounce1=true;
boolean debounce2=true;
boolean play_pause;

void setup(){
music.speakerPin = 9; //Auido out on pin 9
Serial.begin(9600); //Serial Com for debugging 
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}

pinMode(2, INPUT_PULLUP); //Button 1 with internal pull up to chage track
pinMode(3, INPUT_PULLUP); //Button 2 with internal pull up to play/pause
pinMode(3, INPUT_PULLUP); //Button 2 with internal pull up to fast forward

music.setVolume(5);    //   0 to 7. Set volume level
music.quality(1);        //  Set 1 for 2x oversampling Set 0 for normal
//music.volume(0);        //   1(up) or 0(down) to control volume
//music.play("filename",30); plays a file starting at 30 seconds into the track    
}

void loop()

  
  if (digitalRead(2)==LOW  && debounce1 == true) //Button 1 Pressed
  {
  song_number++;
  if (song_number==5)
  {song_number=1;}
  debounce1=false;
  Serial.println("KEY PRESSED");
  Serial.print("song_number=");
  Serial.println(song_number);

  if (song_number ==1)
  {music.play("1.wav",10);} //Play song 1 from 10th second 

  if (song_number ==2)
  {music.play("2.wav",33);} //Play song 2 from 33rd second 

  if (song_number ==3)
  {music.play("3.wav");} //Play song 3 from start

  if (song_number ==4)
  {music.play("4.wav",25);} //Play song 4 from 25th second 

  if (digitalRead(3)==LOW  && debounce2 == true) //Button 2 Pressed
  {
  music.pause();  Serial.println("PLAY / PAUSE");
  debounce2=false;
  }

  if (digitalRead(2)==HIGH) //Avoid debounce
  debounce1=true;

  if (digitalRead(3)==HIGH)//Avoid debounce
  debounce2=true;
}

}

Video

Comments

  • Pat's picture
    Pat
    Aug 22, 2017

    Hi,

    Just curious what speaker you are using for this project? It sounds very nice.

    Pat

  • Aswinth Raj's picture
    Aswinth Raj
    Aug 23, 2017

    Hi Pat, 

    This is a normal 8 ohm speaker. There is nothing special with the speaker, because I have tried it with other speakers and was able to achive the same qulaity.

     

    Thanks

  • Pat's picture
    Pat
    Aug 30, 2017

    The part list says you need a 10uF and 100uF capacitor but the diagram shows 1uF and 10uF in the circuit....which is the correct combination?

  • Aswinth Raj's picture
    Aswinth Raj
    Sep 01, 2017

    Hi Pat,

    I have tested the circuit will both the combinations and they worked fine. You can use either one and the performance will be the same.

  • Orri's picture
    Orri
    Sep 04, 2017

    So I use the 100uF instead of the 10uF and the 10uF in stead of the 1uF?

  • Lorenzo's picture
    Lorenzo
    Sep 02, 2017

    hey, I see in your fritzing pic you put the ground in the + line and the + in the ground line, but the speaker's black wire is connected to the breadbard's blue line (where is connected 5V) and the red wire to the red line (where is connected gnd). Where should I connect amplifier pins?

  • Aswinth Raj's picture
    Aswinth Raj
    Sep 03, 2017

    Yes the firtzing pic has a small representation problem. But, the connections are correct and will work as expected.

    I have mistakenly swapped the positive and ground rails (representation) of the breadboard with the actual positive and ground rails of the circuit. This will not be a problem since the logic of the connection remais the same.

     but the speaker's black wire is connected to the breadbard's blue line (where is connected 5V) and the red wire to the red line (where is connected gnd).

    No, You have completely misunderstood the circuit. The upper positive and ground rails are only powered by +5V and ground. The lower potive and ground rails have not other connection other than the speaker itself.

    You can know more about audio amplifier circuit from here. https://circuitdigest.com/electronic-circuits/lm386-audio-amplifier-circuit

  • miles's picture
    miles
    Sep 11, 2017

    Hi I had one other comment but it has not posted yet so please disregard it. I'm getting the following error how should I resolve it? /Users/milesrichie/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino: In function 'void loop()':
    /Users/milesrichie/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino:54:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    {music.play("1.wav",10);} //Play song 1 from 10th second
    ^
    /Users/milesrichie/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino:56:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    {music.play("2.wav",33);} //Play song 2 from 33rd second
    ^
    /Users/milesrichie/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino:58:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    {music.play("3.wav");} //Play song 3 from start
    ^
    /Users/milesrichie/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino:60:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    {music.play("4.wav",25);} //Play song 4 from 25th second }
    ^
    Sketch uses 12676 bytes (39%) of program storage space. Maximum is 32256 bytes.
    Global variables use 1118 bytes (54%) of dynamic memory, leaving 930 bytes for local variables. Maximum is 2048 bytes.
    avrdude: ser_open(): can't open device "COM1": No such file or directory
    Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

  • Aswinth Raj's picture
    Aswinth Raj
    Sep 13, 2017

    Hi Miles, The above problem is not because of the program but because of your PORT settings. As the error states "can't open device "COM1": No such file or directory" Meaning you have either not selected the correct COM port or have not connected Arduino to PC properly. Try uploading a Blink program to verify your settings before trying this program. Thanks!

  • ahmed's picture
    ahmed
    Sep 21, 2017

    I have the same problem ,, have you solved it??

  • Hrishikesh Morankar's picture
    Hrishikesh Morankar
    Sep 21, 2017

    Hey!! can you please update this project with arduino mega board without the buttons which you've used in this circuit.Also if I removed the buttons is it possible to play multiple files ?

  • Luke Barker's picture
    Luke Barker
    Sep 29, 2017

    Will this work without the LM386 and go direct to head phones?

  • Noam's picture
    Noam
    Oct 09, 2017

    Hi,

    I was able to purchase pololu microSD card breakout board with a 3.3V regulator and level shifters and I am getting error (SD Fail)

    Is it related to Module vendor ?

    Best regards

    Noam

  • Aswinth Raj's picture
    Aswinth Raj
    Oct 09, 2017

    So you have a 3.3V module with 5V level shifter right?

    Make sure the level shifter is working by manually measuirng voltage. 

    The can be either because of your connections or because of your module

  • fitri hanun's picture
    fitri hanun
    Oct 13, 2017

    Hi. i got this error /Users/milesrichie/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino: In function 'void loop()':
    /Users/fitrihanun/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino:54:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    {music.play("1.wav",10);} //Play song 1 from 10th second
    ^
    /Users/fitrihanun/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino:56:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    {music.play("2.wav",33);} //Play song 2 from 33rd second
    ^
    /Users/fitrihanun/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino:58:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    {music.play("3.wav");} //Play song 3 from start
    ^
    /Users/fitrihanun/Documents/Arduino/sketch_sep10a/sketch_sep10a.ino:60:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    {music.play("4.wav",25);} //Play song 4 from 25th second }
    ^

  • wjane's picture
    wjane
    Mar 15, 2018

    Do you know how to solve it?

  • ANAND's picture
    ANAND
    Oct 15, 2017

    hI,can i use this library with atmega 8 mcu.I tried it but it shows some error.like "exit status 1
    Error compiling for board Arduino NG or older."

  • Aswinth Raj's picture
    Aswinth Raj
    Oct 16, 2017

    Sorry ANAND,

    The libraries will not support Atmega8, you should have to upgrade your hardware for this project

  • jim's picture
    jim
    Oct 23, 2017

    Mr Raj. it was a wonderful example. I am thinking to revise the code, but this time using only a single button to turn on and off the music. Here is what i want, im going to used a toggle switch ( on and off). When the button is closed(permanently closed) ,the music will play. When the button is press again the button will be open and the music will stop. However, i wanted to play the music from start again when the button is closed again. Can you help me on this. many thanks

  • bitman's picture
    bitman
    Oct 25, 2017

    Hello,
    Has anyone tried playing the wav clip stored in onboard flash, without the sd card?
    Thanks

  • Aswinth Raj's picture
    Aswinth Raj
    Oct 25, 2017

    Hi Bitman,

    I have not tried it yet. But yes it should work even without a SD card module

  • Kyle's picture
    Kyle
    Nov 07, 2017

    Hi, I am looking to build something like this, but with an option to play one of four .wav files. Is it fairly simple to instead have four buttons to play an audio track, and another to stop. Pressing of any button halting any other .wav file and playing just the programmed .wav file?
    Would appreciate any help as it is for a non-profit group that I help out

  • Nagarajan's picture
    Nagarajan
    Nov 21, 2017

    Sir, Will you please give me a sample coding for arduino program to play the audio files one by one at exact pre- scheduled time interval and switch off as the song ends.

  • robert linder's picture
    robert linder
    Nov 30, 2017

    hi i think ive wired everything correctly but no sound is coming out except an occasional tap? and my lm386 chip is getting really hot.
    im trying to make it so that i can move the buttons off away from the breadboard if possible.

  • robert linder's picture
    robert linder
    Nov 30, 2017

    update the heating problem is fixed but no music is playing when i press the buttons only a tap. checked sd card is being read ok and files are found but still cant get music to play. any suggestions would be helpful

  • robert linder's picture
    robert linder
    Nov 30, 2017

    ok final update before my head explodes!
    im getting a warning about the files when i compile which reads;
    warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    {music.play("1.wav");}
    repeats for other files
    ive looked on the forums and responses just make me more confused as i dont know how to apply the changes they suggest out of the context theyre suggested in. (if that makes sense)
    something along the lines of making the song files constants?
    could this be why my files wont play?

  • AISHA's picture
    AISHA
    Dec 04, 2017

    I not sure how you ended up on his error. But was the code working for you properly the first time. I assume the Amplifier was heating mostly because of a wrong connection. When you rectified the correction the IC might have been completely burnt. So try replacing the IC, incase if you dont have one ignore the amplifier part they will still work just fine but sound will be low.  I tried compiling the same code given here, yet dint get the error you are speaking about

  • SimK's picture
    SimK
    Jan 04, 2018

    Hi,
    How would you connect a speaker using bluetooth module HC06? I am unsure of how to do this.
    Thanks :)

  • Recai's picture
    Recai
    Jan 10, 2018

    Hi. How is it possible to for arduino to give smooth analog signal for music since it can only produce pwm? Can you answer me please. I am confused.

  • AISHA's picture
    AISHA
    Jan 11, 2018

    It is because of the library 

    TMRpcm.h

    This produces analog signal to play music. You have dive deep into how the library works to understand how the signal is produced. 

     

  • jim's picture
    jim
    Jan 13, 2018

    Hello Mr. Raj.
    I was successful in doing the same. However, everytime i press the buttton to play the music i can a loud ticking sound in which i believed coming from the switch. Is there anyway i can eliminate this "click" sound.
    Thanks

  • AISHA's picture
    AISHA
    Jan 15, 2018

    Yes you can add a delay after every time the arduino reads the switch 

  • Mahesh's picture
    Mahesh
    Jan 18, 2018

    I am use the headset if u need any amplification

  • AISHA's picture
    AISHA
    Jan 23, 2018

    No i don't think you will need amplification for Headphones. Let me know how it turns out !

  • Anant Maind's picture
    Anant Maind
    Jan 19, 2018

    Default test file provided in library plays well.But another file not playes properly even i have convered as per your suggestion like

    1. into .wav
    2.sample :1600Hz
    3.Channel :Mono
    4.Bits 8

    Advance pcm format :PCM unsigned 8 bit

  • AISHA's picture
    AISHA
    Jan 23, 2018

    Not play properly in the sense? Are you getting wired sounds? or is it just mute?

  • Awan's picture
    Awan
    Jan 24, 2018

    hello sir my name is awan first sorry to interrupt your time, what kind a speaker when you use in this project because from this tutorial I can't rise up my volume and noise everywhere when I play the music
    thanks

  • Aswinth Raj's picture
    Aswinth Raj
    Jan 24, 2018

    You can use any speaker, you can also use your computer speakers.

    Try with a simple speaker first, if you are satisfied remove the small speaker and replace it with a bigger one. The model of speaker will not affect the working of the circuit. All the best 

  • Mr Manjunatha 's picture
    Mr Manjunatha
    Jan 27, 2018

    SD fail
    KEY PRESSED
    song_number=1
    PLAY / PAUSE
    (in serial monitor)
    the memory card is ok and formatted also.

    I am getting this errors
    please reply for me as soon as possible

  • AISHA's picture
    AISHA
    Jan 30, 2018

    These are not errors,  this means that your buttons are not wired properly check your connections 

  • A.M.L's picture
    A.M.L
    Feb 01, 2018

    hey thanks, but i have a problem ....... when i push the push button first time , track 1 play but when i push it the second ,track 2 didn't play please tell me why and thank you

  • Aswinth Raj's picture
    Aswinth Raj
    Feb 05, 2018

    Sounds odd, it should have played. Make sure the button is working properly 

  • Michael McGuire's picture
    Michael McGuire
    Jul 08, 2018

    The code has a "}" in the wrong place. Move the second to last "}" above the line "if (digitalRead(3)==LOW && debounce2 == true) //Button 2 Pressed"

  • henry's picture
    henry
    Feb 06, 2018

    Can you specify where the error is in the fritzing diagram? I am trying to build this circuit based off the fritzing, but earlier comments make is seem like the fritzing is inaccurate.

  • AISHA's picture
    AISHA
    Feb 07, 2018

    You can build it, if you have any problem use the forum. The circuit diagram is good

  • jun sarte's picture
    jun sarte
    Feb 12, 2018

    i have a problem when i am trying to change track it will not work when i press again the button

  • ahamed Maududi 's picture
    ahamed Maududi
    Feb 14, 2018

    It plays only noise .No playback.what can be the error??

  • SimK's picture
    SimK
    Feb 15, 2018

    Hi,
    How would you connect a speaker using bluetooth module HC06? I am unsure of how to do this.
    Thanks :)

  • Gian.Luke's picture
    Gian.Luke
    Feb 18, 2018

    Hi, thanks for posting this project. I have a question. What's the purpose of putting a 10k resistor in series with a 10uF capacitor to ground at the output? Usually a low resistance (10ohm) and low capacitance (0.05uF) are used in that manner to filter out high frequencies. I think that way you filter out also desired frequencies. Let me know please. Thank you.

  • Henry's picture
    Henry
    Feb 20, 2018

    Can you please CLEARLY specify where the errors are in the breadboard diagram? I am having trouble building the circuit and would like to use the breadboard diagram instead of the schematic. Are there any errors in the schematic, or can I build safely off of that?

  • Saddam Hossain's picture
    Saddam Hossain
    Feb 20, 2018

    Hi,
    You have done a very good job. I am also doing a project like this. I want to add one more button for stopping the music. I tried with the "audio.stopPlayback(); " function . But is not working properly. Do have any idea how to fix this?
    Say, in your current project if you add one more button then what will be the code for stopping the music?

  • Vanshree Bapat's picture
    Vanshree Bapat
    Mar 01, 2018

    Hi. We are currently working on a project to convert ASL into normal speech using Arduino mega 2560. The code and the connections are exactly as given on various sites (CS pin 53 on mega), but at each time it is failing to initialise. Please help us if possible! Thank You

  • AISHA's picture
    AISHA
    Mar 01, 2018

    Which code and circuit are you using? I used the one given here and dint find any problem? What error are you facing? What do you mean by failing to initialise?

  • Ranjeet's picture
    Ranjeet
    Mar 02, 2018

    I connected everything and put code on arduino but it doesnt play the music. You can just hear some noise, buttons do nothing, Whats the problem?

  • Divya's picture
    Divya
    Mar 03, 2018

    hlo, I have tried all the things u have mentioned in ur list. But v r unable to get the audio from the speaker. We hve used a 3ohm speaker. We are getting mgs on monitor screen as"KEY PRESSED
    song_number=1". And no any sound is heard. Can u plz help us out wdt this issue.

  • Aswinth Raj's picture
    Aswinth Raj
    Mar 05, 2018

    If you are getting this message it means the code is working properly. The problem is most likely on your hardware share a pic of your set-up that might help to figure out the problem

  • Divya's picture
    Divya
    Mar 09, 2018

    We have replaced the amplifier circuit with the lm386 module directly. Can you please share the pin connection diagram. Because yet we are getting the same message.

  • Rayan's picture
    Rayan
    Mar 12, 2018

    is it possible to use a lm358 istead of lm386

  • AISHA's picture
    AISHA
    Mar 13, 2018

    Yes you can also use a lm358 in place of lm386. The circuit will vary a bit, google for LM358 amplifier circuits and you will get one.

     

    Also you can make this project even without the amplifier part 

  • Chuck Bryant's picture
    Chuck Bryant
    Mar 15, 2018

    How much Arduino microcontroller memory does this project use?

  • AISHA's picture
    AISHA
    Mar 16, 2018

    Just complie the program on the Arduino IDE and at the end of compilation read the logs and you will find the information your looking for 

  • Siege's picture
    Siege
    Mar 28, 2018

    C:\Users\Acer\Documents\Arduino\sketch_mar21a\sketch_mar21a.ino: In function 'void loop()':

    C:\Users\Acer\Documents\Arduino\sketch_mar21a\sketch_mar21a.ino:66:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    {music.play("1.wav",10);} //Play song 1 from 10th second

    ^

    C:\Users\Acer\Documents\Arduino\sketch_mar21a\sketch_mar21a.ino:69:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    {music.play("2.wav",33);} //Play song 2 from 33rd second

    ^

    C:\Users\Acer\Documents\Arduino\sketch_mar21a\sketch_mar21a.ino:72:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    {music.play("3.wav");} //Play song 3 from start

    ^

    C:\Users\Acer\Documents\Arduino\sketch_mar21a\sketch_mar21a.ino:75:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

    {music.play("4.wav",25);} //Play song 4 from 25th second

    ^

  • Denny's picture
    Denny
    Mar 31, 2018

    Mr Raj, Thank you very much for this project. I found this is very useful and cost saving (no buying mp3 shield), I will build mini music player for my kids.
    thank you :)

  • Karl's picture
    Karl
    Apr 06, 2018

    Hey, there is something not clear in the circuit. Are pins 2 and 4 of the amplifier connected to the positive pin of the speaker? Because in the arduino picture it's not showing

  • Karl's picture
    Karl
    Apr 12, 2018

    Hey, thanks a lot for the project! However, I am having trouble when the music starts playing, sometimes songs just start fast forwarding alone and skipping parts. Also the the code just stops sometimes when the skipping gets really bad. Is this a problem with the wires? or the sampling of my wav files?

  • freakman's picture
    freakman
    Apr 25, 2018

    Hi! Can I use a PAM8403 to amplify the sound?

  • lyramaranan's picture
    lyramaranan
    Apr 25, 2018

    hello, i just want to us if it is possible to control the speed of the stepper motor using the music mp3 plays? and how if it is possible, i need that on our project, i just want to know if it is possible because our professor want our project music box to control the rotation of the balerina through the beat of music, for example the music is upbeat therefore the balerina rotates fast and if the music is slow, the balerina rotates slowly. Thank you.

  • Kughaneshwaran's picture
    Kughaneshwaran
    Apr 27, 2018

    Does the capacitor have to be 25 V or any other voltage

  • Pankaj Borade 's picture
    Pankaj Borade
    Apr 27, 2018

    Hello,
    I want to attach HC05 Bluetooth to control song & servo with mobile. So what is code??

  • mohid's picture
    mohid
    May 13, 2018

    Hi, can you tell me how to increase the volume through hardware.can i do it either by changing capacitors or increase power to the circuit or any other ways you know? thanks!

  • Aswinth Raj's picture
    Aswinth Raj
    May 16, 2018

    Increasing the operating voltage of the Op-amp will help. If you are looking for more volume use a more powerful audio amplifier circuit 

  • Haider Ali's picture
    Haider Ali
    May 20, 2018

    The errors occurred in the code given above is due to music.play() function typecasting is required in this function
    music.play("4.wav",25);
    Corrected function argument is:
    music.play((char *)"4.wav",25);

  • cyrille's picture
    cyrille
    May 22, 2018

    can i use LM358/LM741 instead of LM386?

  • Aswinth Raj's picture
    Aswinth Raj
    May 28, 2018

    Yes cyrille you can also use LM358/LM741 as an amplifier but LM386 has a high gain and will work perfect for an audio amplifier. But still LM358/741 will also work 

  • Peroija's picture
    Peroija
    Jun 05, 2018

    I did everything on this page my professor checked it and said its good but when i power it on nothing happens.

  • Aswinth Raj's picture
    Aswinth Raj
    Jun 06, 2018

    Not everyone (even the experienced)  gets a circuit to work in the first try. Learn to debug a circuit when you don't get an output, this is an important skill in electronics. So break the circuit into smaller parts and check where the output is messing up.

    In this case bypass the amplifier section and connect the speaker directly to check if you are getting any audio

  • Aswinth Raj's picture
    Aswinth Raj
    Jun 06, 2018

    Not everyone (even the experienced)  gets a circuit to work in the first try. Learn to debug a circuit when you don't get an output, this is an important skill in electronics. So break the circuit into smaller parts and check where the output is messing up.

    In this case bypass the amplifier section and connect the speaker directly to check if you are getting any audio

  • Aswinth Raj's picture
    Aswinth Raj
    Jun 06, 2018

    Not everyone (even the experienced)  gets a circuit to work in the first try. Learn to debug a circuit when you don't get an output, this is an important skill in electronics. So break the circuit into smaller parts and check where the output is messing up.

    In this case bypass the amplifier section and connect the speaker directly to check if you are getting any audio

  • Lahiru Attanayake's picture
    Lahiru Attanayake
    Jun 05, 2018

    what are the alternative capacitors i can use for 1uF 25v capacitor?

  • kamz hussain's picture
    kamz hussain
    Jun 10, 2018

    hi, this is good, but how can I change the buttons to have one play one track and the other to play all. thanks for your help

  • cedric's picture
    cedric
    Jun 13, 2018

    hey my friend, anyone have bips sounds? when um push the bottom i have only the bips.

  • Tim's picture
    Tim
    Jun 14, 2018

    Hi, its not entirely clear to me regarding the connections to the push buttons. Do both buttons have a connection to GND and then to the pins 2 and 3 respectively? So the idea is that pulling those pins to GND will trigger the appropriate function?

    Thanks

  • kamz's picture
    kamz
    Jun 23, 2018

    hi, I have a built audio amplifer. the Haljia LM386. it has 2 gnd one in and one VDD. which wires to I connect in this connection

Pages

Log in or register to post Comment