ARDUINO UNO SKETCH
// Arduino Uno sketch sings ROW ROW ROW YOUR
// BOAT on SP0-512
#include <SoftwareSerial.h>
#define txPin 13
#define spkPin 12
#define rxPin 11 // not implemented here
SoftwareSerial Speak(rxPin, txPin);
void setup() {
// initialize serial communication with SP0512
Speak.begin(9600);// set the data rate for the
// SoftwareSerial port
delay(1000); // pause 1 second at
// startup
Speak.println(); // initialize 512 with one
// blank CR (println includes
CR)
delay(500);
}
void loop() {
// NOTE: timing spaces removed for magazine
// listing; add multiple spaces between words
// for timing delays
Speak.println("[S2][G2]rowhh rowhh rowhh
[A2]yer [B2] boat jehnn [A2]dlee [B2]down
[C3]thuh [D3] stream");
waitspeak(); // call waitspeak function
delay (500); // pause for proper song spacing
Speak.println("[G3]merrily [D3]merrily
[B2]merrily [G2]merrily [D3]lie ff [C3]is
[B2]but [A2]uh [G2]dream");
waitspeak(); // call waitspeak function
delay (400);
}
void waitspeak() // function: wait for 512 to
// finish speaking
{
delay (100); // pause 0.1 sec for 512's busy
// line to go high
while (digitalRead(spkPin) == HIGH);
//wait until 512's busy line goes low
delay (100); // pause 0.1 sec after 512's
// speaking line to goes low
}
many different processors. At power-up, it says "Ready" as the "speaking"
LED lights up for a second. That's very
helpful to know when testing your
newly-built circuit for the first time;
9600 baud, 8N1, true serial data is
sent to RoboVoice pin 6 where it
accumulates in a buffer. Speech is
triggered by either a carriage return
(CR, typically a ' 13' character) or filling
up the input buffer.
The latter should be avoided,
since data may be lost while the chip
is speaking. Your program should
initially pause for one or two seconds
while the RoboVoice speaks "ready,"
then send a CR (no data) to initialize
communication.
When you first experiment with
the chip, you will inevitably send some
errant characters. As always, "garbage
in, garbage out" wins, and this may
lock up your chip. Remember, it is a
microprocessor and bad data can
crash it too. Reset the RoboVoice chip
if it gives you the silent treatment
when it should be chatty.
After each line of text is sent,
your program needs a subroutine or
function which waits 0.1 sec for the
speaking line to go high; waits until it
goes low (indicating that it has
finished speaking); then waits 0.1 sec
before sending more data.
The sample programs show this
on the lines indicated. In my initial
experiments, I sent two CRs after each
48 SERVO 11.2012
line to trigger speech before learning
those brief delays were necessary.
Send data (numbers) to the chip
using the same formatting you would
use to print or debug them. For
instance, to make a BASIC Stamp 2
speak the value of variable B0, use
this command:
"[G2]This [A2]is [B2]a
[D3]test" will sing the words
"This is a test".
SEROUT 7,84,[" variable B0
equals ", DEC B0]
Master sending basic text ("hello
world", 13) using serout or speak
commands before trying the many
control codes listed in the datasheet
which change volume, speed, and
pitch. Control codes are sent in capital
letters inside square brackets with
text. From the datasheet:
General TTS pronunciation using
the built-in rules and algorithms is
fairly good; in many cases, you'll do
better by creative misspelling or using
the phonemes listed in the datasheet
mentioned previously.
The RoboVoice chip
— regularly priced
at $24.99 — is available
to SERVO readers at the
special price of $16.99
for the month of
November. See
www.speechchips.com/
shop for details.