#include <SoftwareSerial.h>
#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
TMRpcm tmrpcm;
SoftwareSerial bluetooth(5, 6);//tx,rx
const int led = 8;
String value;
void setup()
{
  tmrpcm.speakerPin = 10;
  Serial.begin(9600);
  bluetooth.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)) 
  {
  Serial.println("SD fail");
  return;
  }
  pinMode(led,OUTPUT);
  digitalWrite(led,LOW);
  //tmrpcm.setVolume(5);
  //tmrpcm.play("hello.wav"); //Used for testing(Do not include in final code)
  //delay(1000);
}
void loop()
{
  if (bluetooth.available())
   {
    value = bluetooth.readString();
    if (value == "hello")
    {
      tmrpcm.setVolume(5);
      tmrpcm.play("hello.wav"); 
      delay(1000);
    }
    if (value == "could you please turn on the led")
    {
      digitalWrite(led,HIGH);
      tmrpcm.setVolume(5);
      tmrpcm.play("ledon.wav"); 
      delay(1000);
    }
    if (value == "turn off the led")
    {
      digitalWrite(led,LOW);
      tmrpcm.setVolume(5);
      tmrpcm.play("ledoff.wav"); 
      delay(1000);
    }
    if (value == "are you similar to alexa")
    {
      tmrpcm.setVolume(5);
      tmrpcm.play("alexa.wav"); 
      delay(1000);
    }
    if (value == "i am sorry")
    {
      tmrpcm.setVolume(5);
      tmrpcm.play("sorry.wav"); 
      delay(1000);
    }
    if (value == "would you like to say something")
    {
      tmrpcm.setVolume(5);
      tmrpcm.play("sub.wav"); 
      delay(1000);
    }
   }
}


