ARDUINO MUSIC PLAYER
This is an arduino atmega328 based audio player.The file type is wav with 8 bit format.Download the sample wav files & LIBRARIES in the link itself.
CONNECTIONS
PROGRAM
#include <SD.h> // need to include the SD library
#define SD_ChipSelectPin 4 //using digital pin 4 on arduino nano 328, can use other pins
#include <TMRpcm.h> // also need to include this library...
#include <SPI.h>
TMRpcm tmrpcm; // create an object for use in this sketch
void setup(){
tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized:
Serial.println("SD fail");
return; // don't do anything more if not
}
tmrpcm.setVolume(5);
tmrpcm.play("electrotechysmedia1.wav"); //the sound file "music" will play each time the arduino powers up, or is reset
}
void loop(){
if(Serial.available()){
if(Serial.read() == 'A'){ //send the letter p over the serial monitor to start playback
tmrpcm.play("electrotechysmedia1.wav");
}
}
Comments
Post a Comment