#include <Servo.h>
Servo myservo1; //Servo for the vertical motion
Servo myservo2; //Servo for the horizontal motion
int servoPos=90;
int servoVPos1=75;
int servoVPos2=105;
int servoHPos1=60;
int servoHPos2=120;
void setup() {
myservo1.attach(9); // attaches the servo on pin 9
myservo2.attach(11); // attaches the servo on pin 11
myservo1.write(servoPos);
myservo2.write(servoPos); //both servos start from the original position of 90 degrees
}
void loop() {
//for the right part of the leg
delay(1000);
myservo1.write(servoVPos1); //The servo motor for vertical motion puts the leg up
delay(1000);
myservo2.write(servoHPos1); //The servo motor for horizontal motion puts leg forward
delay(1000);
myservo1.write(servoPos); //The servo motor for vertical motion puts the leg down
delay(1000);
//for the left part of the leg
delay(1000);
myservo1.write(servoVPos2); //The servo motor for vertical motion puts the leg up
delay(1000);
myservo2.write(servoHPos2); //The servo motor for horizontal motion puts leg forward
delay(1000);
myservo1.write(servoPos); //The servo motor for vertical motion puts the leg down
delay(1000);
}