Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

bauteile:emic_2

Dies ist eine alte Version des Dokuments!




Emic 2: Text-to-Speech Module

Ein simpler Schaltplan für das Modul ist in der Dokumentation unter https://www.parallax.com/sites/default/files/downloads/30016-Emic-2-Text-To-Speech-Documentation-v1.1.pdf zu finden. Sobald alles verkabelt ist könnt ihr dieses Beispielsprogramm testen:

<code java>

include the SoftwareSerial library so we can use it to talk to the Emic 2 module #include <SoftwareSerial.h> #define rxPin 10 Serial input (connects to Emic 2's SOUT pin) #define txPin 11 Serial output (connects to Emic 2's SIN pin) #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);

// set the data rate for the SoftwareSerial port
emicSerial.begin(9600);
digitalWrite(ledPin, LOW);  // turn LED off

/*
  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 ":"
*/
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 { emicSerial.print('V'); emicSerial.print(„0“); Set volume to 0dB (range -48dB (soft) to 18dB (loud))

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);
// Every robot should inherit the three laws of robotics!
// 1. Law of robotics
emicSerial.print('S');
emicSerial.print("A robot may not injure a human being or, through inaction, allow a human being to come to harm.");  // 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);
// 2. Law of robotics
emicSerial.print('S');
emicSerial.print("A robot must obey the orders given it by human beings, except where such orders would conflict with the First Law.");  // 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);
// 3. Law of robotics
emicSerial.print('S');
emicSerial.print("A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws.");  // 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(5000);

}

</code java>

bauteile/emic_2.1436784676.txt.gz · Zuletzt geändert: 2016/01/21 12:45 (Externe Bearbeitung)