Introduction: Arduino Audio Player (Playing Rain Over Me)

About: I call myself a Maker and love technology

This Arduino project is one of the most simple and fun projects you can build with Arduino in 10-15 minutes. The result of this make will be an Arduino Audio Player which will play “.wav” files. It consist of a speaker, a simple transistor acting as an amplifier and a micro-SD card adapter with a micro-SD in it through which the .wav files are loaded and played.

Step 1: What Are the Stuff Required to Make This?

Hardware:

Arduino Uno (Any other Arduino except Due will work)

Micro-SD card adapter - http://www.dx.com/p/spi-microsd-card-adapter-v0-9b...

8-ohms speaker

Micro-SD Card

Mini Breadboard

BC 546b NPN transistor

7k Resistor

Male-to-male jumpers

Software:

Arduino IDE (Latest version is recommended). – https://www.arduino.cc/en/Main/Software

SD Association’s SD Formatter tool. – https://www.sdcard.org/downloads/formatter_4/

TMRPCM library – https://github.com/TMRh20/TMRpcm

Step 2: How Does It Work?

The Arduino in the below circuit loads the .wav files from the micro-SD card. It then generates a signal and outputs it through the speaker connected to digital pin 9. This makes the speaker create sounds and play music. It can play many different songs saved on the micro-SD card. In this tutorial, I have programmed the Arduino Audio Player to play the famous song ‘Rain Over Me”, by Pitbull and Marc Anthony.

The .wav files used in this circuit have a slight limitation in playing audio. As a transistor is used as an amplifier, it cannot read much complex .wav files. Therefore, the .wav files should be converted to:

Samples Per second (Hz): 16000

Channel : Mono

Bits Per Sample: 8

Step 3: Step 1: Converting Files to Much Detailed .wav File Format for Your Arduino Audio Player

You don’t need any software to install in order to convert the songs to .wav files. There is an online music converter to do the work. The link is : http://audio.online-convert.com/convert-to-wav

Follow the steps given below to make songs compatible with your Arduino audio player:

1.Upload a music file or enter a link for the song or music file to be converted. You can even choose files from Dropbox or Google Drive.

2.In optional settings, change bit resolution to 8 bit.

3.Change sampling rate to 16000 Hz.

4.Change audio channels to Mono.

5.Click on Show advanced options.Select PCM format as PCM unsigned 8-bit.

6.Click on Convert and the files are converted!

Step 4: Step 2: Formatting a Micro-SD Card

1.Download the SD Formatter tool from https://www.sdcard.org/downloads/formatter_4/

2.Run the tool as administrator.Select the proper drive to format.

3.Give the card your favourite name by writing it on Volume label and click on the “Format” button.

4.It will prompt you a couple of dialogues. Click on them and your card will be formatted perfectly.

5.Add the previously converted .wav files to the card and save them with simple names such as ’81.wav’.

Step 5: Step 3: Preparing the Circuit

MOSI – pin 11 on Arduino Uno/Duemilanove/Diecimila

MISO – pin 12 on Arduino Uno/Duemilanove/Diecimila

CLK – pin 13 on Arduino Uno/Duemilanove/Diecimila

CS – depends on your SD card shield or module.

Pin 4 is used here for consistency with this Arduino code

Step 6: Step 4: Connect the Arduino and Upload the Code

The code is as follows:

#include "SD.h"

#define SD_ChipSelectPin 4

#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(6); 

tmrpcm.play("rain.wav"); }

void loop(){  }

Step 7: ENJOY!!!

Plug in the power and you have your Arduino Audio Player successfully playing Rain Over Me. Feel the happiness with the energetic starting lines, “Girl my party don’t lie”!!!!! :)

You can check the working demo above.

Thank You.