Serial help.

I have been beating my head against the wall all day. Hopefully someone can help me here.

So in a nut shell the first Arduino is a MEGA 2560. I want it to send the text that the Emic will read (ie: “Hello /n”) to the Arduino Uno that has the Emic mounted on it. then teh Uno will send the text to the Emic board. I did not connect the Emic to the mega, it did not seem to work on the mega but dose work on the UNO, but the uno dose not have room for all my sensors.

Here is the demo that comes with the EMIC board.

/*
  
  Emic 2 Text-to-Speech Module: Basic Demonstration       
                                                         
  Author: Joe Grand [www.grandideastudio.com]             
  Contact: support@parallax.com                            
  
  Program Description:
  
  This program provides a simple demonstration of the Emic 2 Text-to-Speech
  Module. Please refer to the product manual for full details of system 
  functionality and capabilities.

  Revisions:
  
  1.0 (February 13, 2012): Initial release
  
*/

// include the SoftwareSerial library so we can use it to talk to the Emic 2 module
#include <SoftwareSerial.h>

#define rxPin 2   // Serial input (connects to Emic 2 SOUT)
#define txPin 3    // Serial output (connects to Emic 2 SIN)
#define ledPin 13  // Most Arduino boards have an on-board LED on this pin

// set up a new serial port
SoftwareSerial emicSerial =  SoftwareSerial(rxPin, txPin);


void setup()  // Set up code called once on start-up
{
  // define pin modes
  pinMode(ledPin, OUTPUT);
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(23, OUTPUT);
  
  // set the data rate for the SoftwareSerial port
  emicSerial.begin(9600);
  Serial.begin(9600);
  digitalWrite(ledPin, LOW);  // turn LED off
  
  /*
    When the Emic 2 powers on, it takes about 3 seconds for it to successfully
    intialize. 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 ":"
  */
  emicSerial.print('\n');             // Send a CR in case the system is already up
  while (emicSerial.read() != ':');   // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
  delay(10);                          // Short delay
  emicSerial.flush();                 // Flush the receive buffer
}

void loop()  // Main code, to run repeatedly
{
  Serial.print(" Loading Loop NOW ");
  // Speak some text
  digitalWrite(23, HIGH);
  Serial.println("Relay ON");
  emicSerial.print('S');
  emicSerial.print("Hello. My name is the Emic 2 Text-to-Speech module. I would like to sing you a song.");  // Send the desired string to convert to speech
  emicSerial.print('\n');
  digitalWrite(ledPin, HIGH);         // Turn on LED while Emic is outputting audio
  while (emicSerial.read() != ':');   // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
  digitalWrite(ledPin, LOW);
    
  delay(500);    // 1/2 second delay
    
  // Sing a song
  emicSerial.print("D1\n");
  digitalWrite(ledPin, HIGH);         // Turn on LED while Emic is outputting audio
  while (emicSerial.read() != ':');   // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
  digitalWrite(ledPin, LOW);

  while(1)      // Demonstration complete!
  {
    delay(500);
    digitalWrite(ledPin, HIGH);
    delay(500);              
    digitalWrite(ledPin, LOW);
  }
  digitalWrite(23, LOW);
  Serial.println(" relay off ");
}

Thanks for your help.

Don't use software serial with the mega use on of the other hardware serials.

Mark

holmes4:
Don't use software serial with the mega use on of the other hardware serials.

Mark

Or, if you insist on using SoftwareSerial, RTFM, You are NOT using pins that SoftwareSerial works on on a Mega.

Hi guys,
I just recently got stuck with this problem so decided to fix it. Here is an update for the emic2 library to work with hardware UART of Atmega2560. I’ve hard coded it to work with Serial1 of Atmega2560. You can find the library on github

Thanks!