Bluetooth and TMRPCM don't work together.

Hi guys, Simple SD Audio and Bluetooth can work together but i can't run audio files with Simple SD Audio and Arduino Mega, also i have a micro SD product, not SD. (Maybe this is the main problem)

TMRPCM works perfect itself but doesn't work together Bluetooth. My HC 06 is running on Hardware Serial.

Is there any solution for this? Otherwise, I don't use audio files. Thanks.

Can you please post your code (using code tags) and a schematic showing what you are trying to do? It seems like you're having trouble using a Mega to play audio using SimpleSDAudio? Going by the information here it should definitely be possible to use a Mega rather than a Uno.
Using a MicroSD rather than a fullsize SD shouldn't make any difference. I haven't used SimpleSDAudio but I have used TMRPCM with a microSD card before.

TMRPCM works perfect but by itself. SimpleSDAudio don’t work any term, also my connections are true. (For Mega, 44 for Speaker, 50-51-52 (MISO, MOSI, SCK) and 4 (SD_CS) for Micro SD)

With TMRPCM, my codes are looking like this;

#include <SD.h>                      
#define SD_ChipSelectPin 53 
#include <TMRpcm.h>          
#include <SPI.h>

TMRpcm tmrpcm;   

#include <Servo.h>
int aci=90,i;
Servo myservo; 
int gecikme=40;
HardwareSerial &Bluetooth = Serial1;

// Variables used for incoming data
const byte maxDataLength = 20;
char receivedChars[21] ;
boolean newData = false;

// Pins de HC-SR04
const int trigger_sol = 33;
const int echo_sol = 35;

// Pins de HC-SR04
const int trigger_sag = 37;
const int echo_sag = 39;

// Constants for hardware
const byte m_PIN[] = {23,25,27,29};
boolean m_State[] = {false,false,false,false};

const int on_sol = 22;
const int on_orta = 24;
const int on_sag =  26;

const int hareket_sensoru_sol = 38;
const int hareket_sensoru_sag = 40;

int durum;
int engel_oku1;
int engel_oku2;
int engel_oku3;

void setup() {

   Serial.begin(9600);
    myservo.attach(10);
  // Configuración de los pines
    pinMode(trigger_sol, OUTPUT);
    pinMode(echo_sol, INPUT);


   pinMode(trigger_sag, OUTPUT);
   pinMode(echo_sag, INPUT);


  //Engel switchler pull-up olacak


    for (byte pin = 0; pin < 4; pin++) 
    {
         
         
       // Set the LED pins for output and make them LOW
       pinMode(m_PIN[pin], OUTPUT);  digitalWrite(m_PIN[pin],LOW);
    }
    
    pinMode(22,INPUT_PULLUP); // on_sol
    pinMode(24,INPUT_PULLUP); //on_orta
    pinMode(26,INPUT_PULLUP); 


    pinMode(38,INPUT);
    pinMode(40,INPUT);
    
    
  
    

 kafa_test();
 ileri_git(); delay(1000);dur();
 geri_git(); delay(200);dur();
 sola_don(); delay(200);dur();
 saga_don(); delay(200);dur();

 // open serial communication for debugging
    Serial.begin(9600);
    Serial.print("Sketch:   ");   Serial.println(__FILE__);
    Serial.print("Uploaded: ");   Serial.println(__DATE__);
    Serial.println(" ");
     
    //  open software serial connection to the Bluetooth module.
    Bluetooth.begin(9600); 
    Serial.println("Serial started at 9600"); 
          
    newData = false;




 
{
tmrpcm.speakerPin=46;
Serial.begin(9600);
if(!SD.begin(SD_ChipSelectPin))
{
  Serial.println("SD fail");
  return;
}
}


}
//***********************************************************
//***********************************************************
//***********************************************************
//***********************************************************

void loop() {

    {engel_oku1 = digitalRead(22);

   if (engel_oku1 == LOW) {Bluetooth.print("<L,1,0>" );Bluetooth.print("<L,2,0>" );Bluetooth.print("<L,3,1>" );Bluetooth.print("<L,4,0>" ); 
   digitalWrite(23,LOW);digitalWrite(25, HIGH);digitalWrite(27, LOW);digitalWrite(29, HIGH);sistem_test();dur();Bluetooth.print("<L,3,0>" );}

   

   }
   
    {engel_oku2 = digitalRead(24);
   if (engel_oku2 == LOW) {Bluetooth.print("<L,1,0>" );Bluetooth.print("<L,2,1>" );Bluetooth.print("<L,3,0>" );Bluetooth.print("<L,4,0>" ); 
   digitalWrite(23,LOW);digitalWrite(25, HIGH);digitalWrite(27, HIGH);digitalWrite(29, LOW);delay(2000);sistem_test();dur();Bluetooth.print("<L,2,0>" );}

      
      }
   
    {engel_oku3 = digitalRead(26);
  
   if (engel_oku3 == LOW) {Bluetooth.print("<L,1,0>" );Bluetooth.print("<L,2,0>" );Bluetooth.print("<L,3,0>" );Bluetooth.print("<L,4,1>" ); 
   digitalWrite(23,HIGH);digitalWrite(25, LOW);digitalWrite(27,HIGH);digitalWrite(29, LOW);sistem_test();dur();Bluetooth.print("<L,4,0>" );}

    }
         
    recvWithStartEndMarkers();                // check to see if we have received any new commands
    if (newData)  {   processCommand();  }    // if we have a new command do something about it

   { Serial.println(" Hareket Kontrol Ediliyor ");
int buttonState_sol = digitalRead(38);
int buttonState_sag = digitalRead(40);

if (buttonState_sol == LOW) {Serial.println(" SOLDA ENGEL ");
Bluetooth.print("<L,1,0>" );Bluetooth.print("<L,3,1>");Bluetooth.print("<L,2,0>" );Bluetooth.print("<L,4,0>" );tmrpcm.play("91.wav"); 
   digitalWrite(25, HIGH);digitalWrite(29, HIGH);digitalWrite(23, LOW);digitalWrite(27, LOW);
   delay(2000);sistem_test();dur();Bluetooth.print("<L,3,0>");}

   
else if(buttonState_sag == LOW)

{ Serial.println(" SAGDA ENGEL ");
Bluetooth.print("<L,2,0>" );Bluetooth.print("<L,4,1>" );Bluetooth.print("<L,1,0>" );Bluetooth.print("<L,3,0>");tmrpcm.play("91.wav"); 
   digitalWrite(23, HIGH);digitalWrite(27, HIGH);digitalWrite(25, LOW);digitalWrite(29, LOW);delay(2000);sistem_test();dur();Bluetooth.print("<L,4,0>");}
   }



}


//***********************************************************
//***********************************************************
//***********************************************************
//***********************************************************


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++


void sola_don()   // sola dön
{
digitalWrite(23, HIGH);digitalWrite(27, HIGH); delay(100);Serial.println("     SOLA donuyorum    "); durum=1;
}

void saga_don()
{
digitalWrite(25, HIGH);digitalWrite(29, HIGH); delay(100); Serial.println("     SAGA donuyorum    ");durum=1;
}


void ileri_git()  // geri git
{
digitalWrite(23, HIGH);digitalWrite(29, HIGH); delay(100);Serial.println("     ilerliyorum    ");durum=1;
}

void geri_git() // ileri olacak
{
digitalWrite(25, HIGH);digitalWrite(27, HIGH); delay(100);Serial.println("     GERi Gidiyorum    ");durum=1;
}

void dur()
{
    digitalWrite(23, LOW);
    digitalWrite(25, LOW);
    digitalWrite(27, LOW);
    digitalWrite(29, LOW);
    delay(500); Serial.println("     DURDUM    ");
}
//*******************************************************//


void kafa_test()
{
  
  for(i=1;i<=15;i=i+1)
  {
  aci=aci+5;
  myservo.write(aci); 
    // sets the servo position according to the scaled value
  delay(gecikme);   
  }
  Serial.print("1= "); Serial.println(aci); delay(500);
  
    for(i=1;i<=30;i=i+1)
  {
  aci=aci-5;
  myservo.write(aci);  
  delay(gecikme);   
  }
Serial.print("2= "); Serial.println(aci); delay(500);
    for(i=1;i<=15;i=i+1)
  {
    aci=aci+5;
  
  myservo.write(aci);   
   // sets the servo position according to the scaled value
  delay(gecikme);   
  }

Serial.print("3: "); Serial.println(aci); delay(500);
  delay(2000); 
   
  
}

void processCommand()
{
     Serial.print("receivedChars = ");   Serial.println(receivedChars);

    if (receivedChars[0] == 'L')      // do we have a LED command?
    {
        // we know the LED command has a fixed length "L10"
        // and the value at pos 1 is the LED and the value at pos 2 is 0 or 1 (on/off). 
        // 0 and 1 is the same as LOW and HIGH so we can use 0/1 instead of LOW/HIGH
        
        byte mnum = receivedChars[1] - 48;          // convert ascii to value by subtracting 48
        boolean mstatus = receivedChars[2] - 48;
        
        digitalWrite(m_PIN[mnum-1],mstatus);
        m_State[mnum-1] = mstatus;
    }

    receivedChars[0] = '\0';
    newData = false;
}


void sistem_test()
{
  
  for(i=1;i<=5;i=i+1)
  {
  aci=aci+5;
  myservo.write(aci); 
    // sets the servo position according to the scaled value
  delay(gecikme);   
  }
  Serial.print("test1= "); Serial.println(aci); delay(500);
  
    for(i=1;i<=5;i=i+1)
  {
  aci=aci-5;
  myservo.write(aci);  
  delay(gecikme);   
  }
Serial.print("test2= "); Serial.println(aci); delay(500);
  
}

void recvWithStartEndMarkers()
{
     static boolean recvInProgress = false;
     static byte ndx = 0;
     char startMarker = '<';
     char endMarker = '>';
     char rc;
 
     if (Bluetooth.available() > 0) 
     {
          rc = Bluetooth.read();
          if (recvInProgress == true) 
          {
               if (rc != endMarker) 
               {
                    receivedChars[ndx] = rc;
                    ndx++;
                    if (ndx > maxDataLength) { ndx = maxDataLength; }
               }
               else 
               {
                     receivedChars[ndx] = '\0'; // terminate the string
                     recvInProgress = false;
                     ndx = 0;
                     newData = true;
               }
          }
          else if (rc == startMarker) { recvInProgress = true; }
     }
}

My PCM file specifications are like this;

8 bit (Unsigned), 16000 Hz, Mono. If I can use Simple SD Audio, actually there is not a problem, but i can’t.

Why TMRpcm and Bluetooth don't work together? I have HC-05 and also HC-06 products and micro SD Card Shield. Simple SD Audio won't work with my micro SD Card Shield, there is no any possibility, Simple SD Audio don't work with my Shield.

Is there any possibility to play sound on Arduino? Any product? TMRpcm is so useless library with working Bluetooth.

If TMRpcm won't work, i need a product. I have 2 days.

Hi guys, i do. I use Simple SD Audio for sound and ServoTimer2 for servo motor and also bluetooth can work. But there is a big distortion. Probably because of codes that working together, because there is so much codes but this is acceptable for me. Thank you.