   Serial.println();
   Serial.println();
 
+
+  ///////////////////////////////////////////////////// SETUP BLUETOOTH
+  // set the pins to OUTPUT
+  pinMode(bt_power, OUTPUT);  
+  pinMode(bt_key_power, OUTPUT);
+  pinMode(indication_led, OUTPUT);
+  
+  // set the pins to LOW
+  digitalWrite(bt_power, LOW);
+  digitalWrite(bt_key_power, LOW);
+  digitalWrite(indication_led, LOW);
+
+  // make sure the key has been LOW for a bit
+  delay(100);
+  
+  // set the key pin to High
+  digitalWrite(bt_key_power, HIGH);
+  
+  // small delay
+  delay(100);
+  
+  // now power on the BT
+  digitalWrite(bt_power, HIGH);
+  
+  // start our serial so we can send and recieve
+  // information from the BT module
+  Serial.begin(9600);
+  // initiate the BT serial at 38400 which is the default 
+  // speed at which the BT AT mode operates at
+  BT.begin(38400);
+  Serial.println("BT started at 38400");
+  
+  // self explanatory
+  Serial.write("For a list of commands, visit: \n");
+  Serial.write("Type AT commands  \n\n");
+  
+  // process complete turn on led 13
+  digitalWrite(indication_led, HIGH);
+  
+  // Send an "AT" command to the AT (without quotes)
+  // if response is OK, then we are connected
+  // and ready to program the BT module
+  
+  ///////////////////////////////////////////////////// END SETUP BLUETOOTH
+  
   //Initialize the SdCard.
   if(!sd.begin(SD_SEL, SPI_FULL_SPEED)) sd.initErrorHalt();
   // depending upon your SdCard environment, SPI_HAVE_SPEED may work better.

 * \ref Error_Codes
 */
  char buffer[6]; // 0-35K+null


// constants

  //check result, see readme for error codes.
  }

  #if (0)
  // Typically not used by most shields, hence commented out.
  //Serial.println(F("Applying ADMixer patch."));
  if(MP3player.ADMixerLoad("admxster.053") == 0) {
    //Serial.println(F("Setting ADMixer Volume."));
    MP3player.ADMixerVol(-3);
  }
  #endif

void loop()
{
  ///////////////////////////////////////// BLUETOOTH
  // listen for a response from the HC-05 and write it to the serial monitor
  if (BT.available()){
    c = BT.read();
    Serial.write(c);
  }
  // listen for user input and send it to the HC-05
  if (Serial.available()){
    c = Serial.read();
    Serial.write(c);
    BT.write(c);
  }
  ///////////////////////////////////////// END BLUETOOTH
  
  if (digitalRead(A0)==HIGH)
  {
    int reading = digitalRead(in);
  
  
    if ((millis() - lastStateChangeTime) > dialHasFinishedRotatingAfterMs) {
    // the dial isn't being dialed, or has just finished being dialed.
      if (needToPrint) {
      // if it's only just finished being dialed, we need to send the number down the serial
      // line and reset the count. We mod the count by 10 because '0' will send 10 pulses.
      
      if(count==1){
        MP3player.stopTrack();
        Serial.println("Dail 1-9 to select one track.");
        Serial.println();
      }
        
      else{
        Serial.print("You select track: ");
        Serial.println(count-1);
        Serial.println("The music is playing");
        MP3player.stopTrack();
        MP3player.playTrack(count-1);
        Serial.println();
        Serial.println("Hey,you can add some sound effect!");
        Serial.println();
      }
    
    
      needToPrint = 0;
      count = 0;
      cleared = 0;
      }
    } 
  
    if (reading != lastState) {
      lastStateChangeTime = millis();
    }
      if ((millis() - lastStateChangeTime) > debounceDelay) {
      // debounce - this happens once it's stablized
        if (reading != trueState) {
        // this means that the switch has either just gone from closed->open or vice versa.
        trueState = reading;
          if (trueState == HIGH) {
          // increment the count of pulses if it's gone high.
          count++; 
          needToPrint = 1; // we'll need to print this number (once the dial has finished rotating)
          } 
        }
      }
      lastState = reading;
  }
  else {
    MP3player.stopTrack();
  }
} 

