Sync Mp3 With servo

Hello,

I am a beginner at programming and I am working on an animatronic dragon. I got the jaw to move up and down but now I want it to roar/make dragon noises. I was wondering how I would sync the sound ("Voice") with the movement of the servo. To move the servo I am using the ardunio sweep code shown below. And for the voice I will be using a dragon roar sound effect from youtube.

Thanks in advance.

Here is the jaw servo code. (It is the sweep code, but inverted)

/* Sweep
by BARRAGAN http://barraganstudio.com
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald

*/

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 180; // variable to store the servo position

void setup() {
myservo.attach(10); // attaches the servo on pin 10 to the servo object
}

void loop() {
for (pos = 180; pos >= 90; pos -= 1) { // goes from 180 degrees to 900 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 90; pos <= 180; pos += 1) { // goes from 90 degrees to 180 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

1 Like

What type of signal is needed to trigger the sound and does it automatically stop or does it need to be stopped explicitly ?

Does the sound device (what is it ?) act as a stand alone system, ie once started it continues, or does it need to be refreshed to make it carry on ?

For the end product I plan on using a MOVI Shield but for now (For testing and prototyping proposes I would like to use a computer and have the downloaded sound effect and call upon it when needed)

The signal would stop automatically (once the audio is done) I would call upon the signal by using voice command (Using the MOVI Shield) or button (Using computer)

1 Like

For the end product I plan on using a MOVI Shield but for now (For testing and prototyping proposes I would like to use a computer and have the downloaded sound effect and call upon it when needed)

The signal would stop automatically (once the audio is done) I would call upon the signal by using voice command (Using the MOVI Shield) or button (Using computer)

I am not familiar with that shield, but can it play MP3 files ?

yes