I download the SpeakJet software which has a little dictionary of common words and work out the commands to make it say 'I Can See You' in a spooky robot voice, then change the pitch based on the reading from the ping sensor. Both the PING and motion sensor are plugged in, so we now have this circuit (I've left off some of the less relavent connections to the speak jet to keep it simple):
PING, Motion and SpeakJet connected to Arduino RCX (serial) is connected to GPIO3 |
Changing the pitch is quite simply a case of sending the SpeakJet a pitch change command (22), followed by a number from 0 to 255 (although 100 to 255 seem to work more effectively). Since the ping sensor is plugged in, all I need to do is modify the code to:
- Read the PING sensor value
- Map it to a range between 100 and 255
- Send the pitch change command to the new value
- Send commands to say the message
- Read PING and set pitch
- Send say 'I' command
- Read PING and set pitch
- Send say 'Can' command
- Read PING and set pitch
- Send say 'See' command
- Read PING and set pitch
- Send Say 'You' command
- Speak jet says 'I Can See You'
- Read PING and set pitch
- Send say x command
- Wait for Speak Jet To Finish Saying It
- Read PING and set pitch
- etc etc etc
So how do I know when the speak jet has finished talking? Well, remember the extra output pins on the speak jet - Ready, Speaking and Buffer 1/2 full? If I connect the Speaking pin back into the Arduino I will be able to detect when the Speak Jet is actually saying words. The circuit modification is very simple:
And with a bit code to add the wait it works! After each word is said the pitch will be set base on how close something is to the ping sensor. This video demonstrates it quite nicely (if vid broken check here):
All good! Now for one final trick I hook up a push button to the code that can be hit to say hello just for fun (if broken check here):
I spend the rest of the day neatening up my wiring so it's not a hideous mess of knots and tangles and will actually fit in a robot when I put it there.
-Chris
-Chris
No comments:
Post a Comment