audio

#include <SD.h> // need to include the SD library
//#define SD_ChipSelectPin 53 //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 53 //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

unsigned long time = 0;

void setup(){

  tmrpcm.speakerPin = 46; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
  //Complimentary Output or Dual Speakers:
  //pinMode(10,OUTPUT); Pin pairs: 9,10 Mega: 5-2,6-7,11-12,46-45 
  tmrpcm.volume(100);
  Serial.begin(115200);
  pinMode(13,OUTPUT); //LED Connected to analog pin 0
  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

  }
  else{   
    Serial.println("SD ok");   
  }
  tmrpcm.play("song.wav");
  
  //the sound file "music" will play each time the arduino powers up, or is reset
}



void loop(){  

 
   

}

void play()
{
    tmrpcm.play("song.wav");
}

Comments