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
}
}