The Arduino talking! How is it? Connect speaker and play audio files



I this tutorial we will learn how to play audio files with the Arduino. For this we will use speaker. Also we will use SD card module for keep the audio files.
After this tutorial you can make mini mp3 player using the Arduino.

--------------------

Required Hardware

Arduino Board - https://goo.gl/Rqc5w2
SD Card Module - https://goo.gl/VCv6tJ
Mini Speaker - https://goo.gl/VZshhk
2GB MicroSD - https://goo.gl/rVLYFr
SD Card Reader - https://goo.gl/MUWEW1
Jump Wires - https://goo.gl/n5ljN3

Mid-year Promotion -- https://goo.gl/CreUkc
Arduino & DIY Kits -- https://goo.gl/uwr19e
Flash deals Electronics -- https://goo.gl/qyy5EB
Arduino Basic Starter Kit -- https://goo.gl/Tb7dfq
Recommended Site -- https://goo.gl/V9nYtx

--------------------

About the SD Card Module Adapter


The module (MicroSD Card Adapter) is a Micro SD card reader module, and the SPI interface via the file system driver, microcontroller system to complete the MicroSD card read and write files.

Support Micro SD Card (<=2G), Micro SDHC card (<=32G)
The level conversion circuit board that can interface level is 5V or 3.3V
Power supply is 4.5V ~ 5.5V, 3.3V voltage regulator circuit board
Communication interface is a standard SPI interface

--------------------

Connections

SD Card Module VCC connect to +5V of the Arduino Board
Module GND connect to GND of the Arduino Board
Module CS connect to digital 4 pin of the Arduino
Module SCK connect to digital 13 pin of the Arduino
Module MOSI connect to digital 11 pin of the Arduino
Module MISO connect to digital 12 pin of the Arduino

Connection of the Speaker

We will connect two wires to the speaker jack
I use hot silicone (for remove it again). You can use solder if you like.
One wire from the speaker jack will connect to GND of the Arduino.
The other wire will connect to digital input 9 of the Arduino.
(The library use digital pin 9)

--------------------

Create and Convert of audio file

We will transfer the audio files to the Arduino via SD card
Connect your SD card to your computer with a card reader
The type of audio file we need to use is WAV
I recorded the audio with the phone application and I used it by converting it
You can use any song or sound if you want
I used an online website to convert the audio file. You can use a different website if you want.

Upload your audio you want to convert to WAV
Then we change the settings as below
bit resolution: 8 bit
sampling rate: 16000 Hz
audio channels: mono
Then we press Convert File button
Our WAV audio file is ready
Copy the file into the SD card
Insert the SD card into the SD card module

--------------------

Get the Library - https://goo.gl/KehFmd

--------------------

Voice Recognition Module

In the coming days I will make a project with Voice Recognition Module. 
We will send any voice command and in reaction to this command the Arduino will answer to us.
If you yet do not have a Voice Module, you can buy this module from the link in the below.

Voice Module - https://goo.gl/J18ChT
USB to TTL Module - https://goo.gl/hRsKP0

--------------------

Get the Source Code
#include <SD.h>                           //include SD module library
#include <TMRpcm.h>                       //include speaker control library

#define SD_ChipSelectPin 4                //define CS pin

TMRpcm tmrpcm;                            //crete an object for speaker library

void setup(){
  
  tmrpcm.speakerPin = 9;                  //define speaker pin. 
                                          //you must use pin 9 of the Arduino Uno and Nano
                                          //the library is using this pin
  
  if (!SD.begin(SD_ChipSelectPin)) {      //see if the card is present and can be initialized
    
    return;                               //don't do anything more if not
  }
  
  tmrpcm.setVolume(6);                    //0 to 7. Set volume level
  tmrpcm.play("1.wav");         //the sound file "1" will play each time the arduino powers up, or is reset
}

void loop(){}