I got it to work! Thanks for all the help. Here is the new code if anyone ever needs it.
As part of testing I switched to Newsoftserial, but both work. Not sure which I should stay with. I read something about it and servos which i will be using.
/*
Testing Sketch for Robot
*/
//Soft serial library used to send serial commands on pin 2 instead of regular serial pin.
#include <NewSoftSerial.h>
//Define the Pin Numbers of the Voicebox shield for the sketch.
#define E0 5
#define E1 6
#define E2 7
#define E3 8
#define E4 9
#define E5 10
#define E6 11
#define E7 12
#define RDY 13
#define RES 3
#define SPK 4
//Pin 2 of the shield should be wired to the TTS256 chip.
#define txPin 2
//Create a SoftSerial Object to send strings to the TTS256 chip.
NewSoftSerial speakjet(0, txPin);
//Create a message buffer to hold the ascii message to be converted to sound
char message[128]="";
char cmd[3]="";
int cmdCode;
void setup()
{
//Configure the pins for the SpeakJet module
pinMode(txPin, OUTPUT);
pinMode(SPK, INPUT);
//Set up a serial port to talk from Arduino to the SpeakJet module on pin 3.
speakjet.begin(9600);
//Set up a serial port to get the ascii message from the host
Serial.begin(9600);
//Configure the Ready pin as an input
pinMode(RDY, INPUT);
//Configure Reset line as an output
pinMode(RES, OUTPUT);
//Configure all of the Event pins as outputs from Arduino, and set them Low.
for(int i=E0; i<=E7; i++)
{
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}
//All I/O pins are configured. Reset the SpeakJet module
digitalWrite(RES, LOW);
delay(100);
digitalWrite(RES, HIGH);
delay(1000);
char sounds[] = {200, 201, 202, 203, 220, 221, 222};
speakjet.println(sounds);
}
void loop()
{
//Get a message from the serial port
getMessage(message, cmd);
//Convert cmd from char to int
cmdCode = atoi(cmd);
//Send the message to the TTS256
speakjet.println(message);
delay(1000);
while(digitalRead(RDY)==0);
speakjet.println(cmdCode, BYTE);
Serial.println(message);
//Wait 12ms before checking the ready line (specified in TTS256 datasheet)
delay(12);
//Wait for the Speakjet to become 'ready' before sending more text.
while(digitalRead(RDY)==0);
}
//Function: getMessage(char *)
//Description: Retrieves a string from the Serial port. Doesn't return the string until a carriage return character is detected.
//Inputs: None
//Outputs: char * message - The message received on the serial port.
//Returns: Nothing
//usage: getMessage(english_sentance);
void getMessage(char * message, char * cmd)
{
char in_char=0; //Create a character to store the incoming byte from the serial port.
//Wait for a character to come into the serial port
while(Serial.available() <=0);
//Copy the incoming character to our variable.
in_char=Serial.read();
//Keep retreiving characters until the 'end of sentance(0x0D)' character is received.
while(in_char != 0x0D){
if (in_char == 0x5C)
{
while (in_char != 0x0D){
while(Serial.available() <=0); //Now wait for the next character...
in_char = Serial.read();
*cmd++=in_char;
}
}
else {
*message++=in_char; //Every time we receive a character we should add the character to the message string.
while(Serial.available() <=0); //Now wait for the next character...
in_char = Serial.read(); //and copy it to the variable again.
}
}
*message='\0'; //Strings must end with a Null terminator so we need to add this to our message.
*cmd='\0';
return;
}