bts audio 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

int counter=0;
unsigned int leda5;
#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(){
pinMode(2,INPUT_PULLUP);
pinMode(A5,OUTPUT);
pinMode(8,OUTPUT);
  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(6);
 
 


}


void loop(){  
 
  leda5=leda5+1;

  if(leda5>200)
  {
    leda5=0;
  }
  if(leda5<100)
  {
  digitalWrite(A5,LOW);
  }
  else
  {
    digitalWrite(A5,HIGH);
  }
   digitalWrite(8,HIGH);
  Serial.println(counter);
  Serial.println(leda5);
 if(digitalRead(2)==LOW)
 {
  
  delay(1000);
  tmrpcm.stopPlayback();
  counter=counter+1;
  if(counter>4)
  {
    counter=0;
  }
 }
 if(!tmrpcm.isPlaying())
 {
   if(counter==1)
   {
   tmrpcm.play("song2.wav"); 
   }

   
   if(counter==2)
   {
   tmrpcm.play("song4.wav"); 
   }
   if(counter==3)
   {
   tmrpcm.play("song5.wav"); 
   }
    if(counter==4)
   {
   tmrpcm.play("new.wav"); 
   }
 }
}

  
  

 For All Electronics Projects




DOWNLOAD LIBRARIES HERE

ARDUINO AUDIO SAMPLE DOWNLOAD


Post a Comment

0 Comments