Hello,
I want use my Mini Maestro board to create several pre-made sequences and execute them with my Arduino. I have an Arduino shield called a MOVI Shield. The MOVI Shield is a speech synthesizer and it allows me to execute voice commands (For example: I say “Turn on light” and the robot will turn on the light and respond with “Ok”). I was wondering if it was possible to have the servos connected to the Maestro and when I say “Activate sequence 1” the Arduino will tell the Maestro to play Sequence 1 and if I say “Play sequence 2” it will play sequence 2 (I hope to have more than 1 pre-programmed sequence, if that’s possible).
I used the MOVI Shield because it is simple to understand and program. You can get a better understanding of it by taking a look at the code down below or by checking out the website.
This is what my code looks like right now (See code below). I have programmed servo positions and values into it to make my robot move but it doesn’t work as well, compared to when I create a sequence on the Maestro. Plus, the Maestro lets me control the speed of the servos a lot easier which is very important for this project. (I hope to replace all my current servo positions and values with ones from the Maestro. Since the Maestro seems to work a lot better).
(You should know that I am a beginner at programming so it would be greatly appreciated if you could show me with lots of detail how this can be done).
Thanks in advance.
#include <MOVIShield.h>
#include <Servo.h>
//Pins where positive wire of LED connects. (4=Chest Armour Led 7=Eye LED 8=Shield LED)
int led1=4;
int led2=7;
int led3=8;
Servo myservo;
//Define Servo
Servo servo1; //Torso
Servo servo2; //R-Shoulder
Servo servo3; //R-Bicep
Servo servo4; //L-Shoulder
//Servo position in degrees
int servoPos = 0;
int servo1Pos=90;
int servo2Pos=0;
int servo3Pos=0;
int servo4Pos=180;
MOVI recognizer (true); //Get a MOVI object, true enables serial monitor interface, rx and tx for alternate communication pins on AVR architecture boards
void setup()
{
//Define LED pins as outputs
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
//Define servo pins
servo1.attach(3); //attach servo 1 to pin 3
servo2.attach(5);//attach servo 2 to pin 5
servo3.attach(6);//attach servo 3 to pin 6
servo4.attach(9);//attach servo 4 to pin 9
recognizer.init();
recognizer.callSign(F("Sergey")); //Train callsign (may take 20 seconds)
recognizer.addSentence(F("Activate display mode")); //1 (Turns on lights)
recognizer.addSentence(F("Activate stealth mode")); //2 (Turns off lights)
recognizer.addSentence(F("Shutdown")); //3 (Turn off all LEDs and puts servos to rest position)
recognizer.addSentence(F("At ease")); //4 (Servos go to home postion but LEDs stay on)
recognizer.addSentence(F("Activate Shield")); //5 (Turns on LED for Riot Shield)
recognizer.addSentence(F("Pose")); //6 (SERGEY strikes a pose)
recognizer.addSentence(F("Defensive Mode")); //7 (Shield Strobes)
recognizer.train();
}
void loop() {
int res = recognizer.poll();
if (res == 1) {
recognizer.say("Display mode activated");
digitalWrite(led1, HIGH); //Turns on LED connected to pin 4
digitalWrite(led2, HIGH); //Turns on LED connected to pin 7
recognizer.ask();
}
if (res == 2) {
recognizer.say("Stealth mode activatedn");
//Turns off all LEDs
digitalWrite(led1, LOW); //Turns off LED connected to pin 4
digitalWrite(led2, LOW); //Turns off LED connected to pin 7
digitalWrite(led3, LOW); //Turns off LED connected to pin 8
}
if (res == 3) {
recognizer.say("Deactivating");
//Turns off all LEDs
digitalWrite(led1, LOW); //Turns off LED connected to pin 4
digitalWrite(led2, LOW); //Turns off LED connected to pin 7
digitalWrite(led3, LOW); //Turns off LED connected to pin 8
servo1.write(90);// set torso to home/rest position
servo2.write(0);// set R-Shoulder to home/rest position
servo3.write(0);// set R-Bicep to home/rest position
servo4.write(180);//set L-Shoulder to home/rest position
}
if (res ==4) {
recognizer.say("Yes, commander");
//Turns off all LEDs
digitalWrite(led1,HIGH); //Turns on LED connected to pin 4
digitalWrite(led2, HIGH); //Turns on LED connected to pin 7
digitalWrite(led3, HIGH); //Turns on LED connected to pin 8
servo1.write(90);// set torso to home/rest position
servo2.write(0);// set R-Shoulder to home/rest position
servo3.write(0);// set R-Bicep to home/rest position
servo4.write(180);//set L-Shoulder to home/rest position
}
if (res ==5) {
recognizer.say("Sheild activated");
digitalWrite(led3, HIGH); //Turns on Shield LED
}
if (res ==6) {
recognizer.say("Pose initiated");
//Test code
//Defensive Pose
servo1.write(90);//We are controlling the Torso
for (servoPos = 0; servoPos <= 135; servoPos += 1) //Goes from 0 degrees to 135 degrees
servo2.write(servoPos); //We are controlling R-Shoulder
delay(8000);// waits 8sec for the servo to reach the position
for (servoPos = 0; servoPos <= 90; servoPos += 1) //Goes from 0 degrees to 90 degrees
servo3.write(servoPos); //We are controlling R-Bicep
delay(10000);// waits 10sec for the servo to reach the position
for (servoPos = 180; servoPos <= 90; servoPos += 1) //Goes from 180 degrees to 90 degrees
servo4.write(servoPos); //We are controlling L-Shoulder
delay(8000);// waits 8sec for the servo to reach the position
//End of test code
}
if (res ==7) {
recognizer.say("Get Back! Get Back!");
digitalWrite(led3, HIGH); //Turns on Shield LED
delay(5000);
digitalWrite(led3, LOW);
}
}`