I am creating 3 fish that sing with 6 motors (3 x mouths and 3x eyes)
I am wanting to Press a Button and both audio and Servos begin a sequence.
I have the following code so when I press a button the Servos move to a random Servo code I found. I am wanting the Servo’s to move to the mp3 accurately so they look like they are talking. Is there a way to control the servos with an external joystick and the movements be live recorded into arduino code so I can run the code back in Arduino?
Heres the Code:
Servo myservo1;
Servo myservo2;
Servo myservo3; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos =0; // variable to store the servo position
void setup() {
{
myservo1.attach(9);
myservo2.attach(6);
myservo3.attach(5); // attaches the servo on pin 9 to the servo object
}
{
myservo1.write(180);
delay(2000); ////stops motor for 8 seconds
for(pos = 180; pos>=0; pos-=1)// goes from 180 degrees to 0 degrees
myservo2.write(180);
delay(2000); ////stops motor for 8 seconds
for(pos = 180; pos>=0; pos-=1)// goes from 180 degrees to 0 degrees
myservo3.write(180);
delay(2000); ////stops motor for 8 seconds
for(pos = 180; pos>=0; pos-=1)// goes from 180 degrees to 0 degrees
{
myservo1.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(10); // waits 15ms for the servo to reach the position
myservo3.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
myservo1.write(0);
delay(4000); //stops motor for 4 seconds
for(pos = 0; pos <= 180; pos +=1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
}
void loop() {
}