/* YourDuinoStarter Example: The BusyBox for OSCAR    BBtry-TTS-3
  - WHAT IT DOES: Reacts to buttons, makes lights, noises.. speech
  Uses the Emic 2 Text-to-Speech Module.
  - SEE the comments after "//" on each line below
  - CONNECTIONS:
   - Pin   10  // Serial input (connects to Emic 2's SOUT pin)
   - Pin   11  // Serial output (connects to Emic 2's SIN pin)
  - V1.00 04/07/2018
   terry@yourduino.com */

/*-----( Import needed libraries )-----*/
// include the SoftwareSerial library so we can use it to talk to the Emic 2 module
#include <SoftwareSerial.h>
#include <SD.h>  // Needed by the EMIC2 library, though not utilized in this example
#include "EMIC2.h"

/*-----( Declare Constants and Pin Numbers )-----*/
#define RX_PIN  5  // Connect SOUT pin of the Emic 2 module to the RX pin
#define TX_PIN  6  // Connect SIN pin of the Emic 2 module to the TX pin)
#define ledPin 13  // Most Arduino boards have an on-board LED on this 

#define VERBOSE
/*-----( Declare objects )-----*/
EMIC2 emic;  // Creates an instance of the EMIC2 library
// set up a new serial port
//SoftwareSerial emicSerial =  SoftwareSerial(rxPin, txPin);

/*-----( Declare Variables )-----*/


void setup()   /****** SETUP: RUNS ONCE ******/
{
  // define pin modes
  pinMode(ledPin, OUTPUT);

  // Initializes the EMIC2 instance
  // The library sets up a SoftwareSerial port
  // for the communication with the Emic 2 module
  emic.begin(RX_PIN, TX_PIN);
  /* When the Emic 2 powers on, it takes about 3 seconds for it to successfully
    initialize. It then sends a ":" character to indicate it's ready to accept
    commands. If the Emic 2 is already initialized, a CR will also cause it
    to send a ":"
  */

  emic.setVoice(0);  // Sets the voice (9 choices: 0 - 8)
  emic.setVolume(18);

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{

  emic.speak("Hey, Oscar. is this working? ");
  delay(2000);
  emic.speak("Where is GrandMom?");
  delay(2000);
  emic.speak("Tell her to get to work");  
//  emic.speak(3.14);  // It accepts various alphanumeric or numeric data types

 // emic.speak(":-)0 Let's now sing a song");
  //   emic.speakDemo(1);
  while (1);

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/



//*********( THE END )***********