In this instructables we will learn how to play a mp3 file with arduino without using any audio module, here we gonna use PCM library for Arduino which plays 16 bit PCM of 8kHZ frequency so lets do this.
Step 1: Gather Your Components
so in order to do this we need a few components very firat An Arduino & then a speaker 0.5w to 10 w any speaker will do the job then you need to buy a transistor for amplification if your speaker is higher than 0.5w as mine was 3 w so i used a TIP 120 transistor dor amplifying the audio you can use any audio amplifier too.
Buying links. -
Items to Buy (affiliate link) -
TIP 120 transistor -
Step 2: Connections
The connections are really simple if you are using 0.5watt speaker then directly connect the +ve pin of speaker to digital pin 11 on Arduino & -ve pin of speaker to gnd & if using 3 watt speaker then use a tip120 transistor & connect the 11 of Arduino to the base of transistor and -ve pin of speaker to the collector of the transistor & emitter of the transistor to the gnd pin on Arduino.
IIf having issues with connection refer video for help.
Step 3: Download Required Files
To do this you will need few files first of all PCM.zip file to play PCM audio from arduino.
ThEN we will need Audacity software to convert a normal mp3 audio to a 16bit PCM 8hkz audio
& Lastly we need a encoder software to encode that audio into data which we can paste in the code.
DOWNLOAD Audacity -
Download PCM.ZIP & Encoder software (file named as Arduino MP3.zip) -
Step 4: Prepare Audio & Convert It Into Data
the important step is to prepare the audio data.so very first we will need a mp3 file either you record one or get one from anywhere then open that file into Audacity and & click on format then select 16 bit pcm then go down & select frequency of audio to 8000hz & export the audio as mp3.
Then open encode audio software & navigate to the audio file we generated froma audacity then you'll get a message audio copied to clipboard successfully.
Step 5: Coding Part
so the next part is coding part , so as you downloaded the the Arduin mp3.zip file which contains PCM.zip file so add this PCM.zip file as a library to the arduino & then open the playback example available in the that PCM library , & there in the sketch you have to edit the 2nd line of code in sample arrray which is of programem type you need to remove all the data in that aray & paste the data which is copied to the clipboard by the encode audio software.
Step 6: Upload the Code
so finally our code is ready so upload it to the arduino & you'll hear your recorded audio from speaker , enjoy it & if you have any issues or want to about this in deep just refer the video provided.