Hello, I’m relatively new to using the Arduino platform. As a high school student, I have been tasked to create a program that will allow me to use the Speakjet chip as well as running a servo in time with the “words.” I have already been experimenting with the program and I have completed the hardwiring. I’ve definitely encountered a few problems. I have read that using the Speakjet chip can lead to word overflow if you were to use too much in a phrase. When alone, my program for the phrase I want the robot to say plays fine. Also, the servo program I have made works like I need it to. The problem I’m facing is when I add both elements of the program together, it has problems working. The concept works and for the first three phrases both the motor and speech work like I need them to. However, if I add the rest of my program, it starts to go off course. In addition, after the first loop play through it starts to add in random noises and slur its phrases. I’ve added in caps for noise reduction near the servo and tried to take the program out of the loop completely.
Any help or advice would be appreciated. My program is listed below; please remember I am a novice at this.
// set up a new software serial port
//rxPin: the pin on which to receive serial data
//txPin: the pin on which to transmit serial data
#include <SoftwareSerial.h>
#include <Servo.h>
#define txPin 2
#define rxPin 3
// set up the SoftwareSerial port to connect to the SpeakJet
SoftwareSerial SpeakJetSerial = SoftwareSerial(rxPin, txPin);
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(5); // attaches the servo on pin 9 to the servo object
// define pin modes for tx, rx pins:
//pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
SpeakJetSerial.begin(9600);
}
void loop()
{
// char array holding the 'lets make robots' string we want to speak
char SayIt[] = {140,154};
SpeakJetSerial.println(SayIt); // send it to the SpeakJet
val = 25; // reads the value of the potentiometer (value between 0 and 1023)
myservo.write(val); // sets the servo position according to the scaled value
delay(600); // waits for the servo to get there
char SayIt2[] = {157,183};
SpeakJetSerial.println(SayIt2); // send it to the SpeakJet
val = 100; // reads the value of the potentiometer (value between 0 and 1023)
myservo.write(val); // sets the servo position according to the scaled value
delay(500); // waits for the servo to get there
char SayIt3[] = {132,166};
SpeakJetSerial.println(SayIt3); // send it to the SpeakJet
val = 50; // reads the value of the potentiometer (value between 0 and 1023)
myservo.write(val); // sets the servo position according to the scaled value
delay(600); // waits for the servo to get there
// infinite do-nothing loop
char SayIt4[] = {128,153};
SpeakJetSerial.println(SayIt4); // send it to the SpeakJet
val = 100; // reads the value of the potentiometer (value between 0 and 1023)
myservo.write(val); // sets the servo position according to the scaled value
delay(600); // waits for the servo to get there
delay(10000);