Thanks all for the replys.

Groove - "Har Har".

Bagdi - I understand the steep learning curve. I too took a while to get my code to work. At this point I haven't used any timers yet for the legs. I only did one. I still need to buy the rest of the servos, a controller and Mega. I saw your video when I was searching for info. It would be nice to see your code.

Peter. Thanks for the advice. I'm calculating foot position as a function of the distance it is from the coxa servo (hip) pivot point.

I'm incrementing the distance per one degree of coxa servo rotation and getting the two leg servo angles as the distance increases or decreases. This was based on a CAD layout. I'd be interested in understanding how I might use time as a means to move the foot. I'm not sure how to calculate that.

Here's my code. I'm using delay just to slow the motion down for testing. I plan to use millis later.

//This is a 3DOF hexapod algorithm using trig funcions with a

//tibia length of 3.633in, a femur length of 2.00in and coxa

//length of .77in and the coxa servo pivot 2.435in above the floor.

#include <Servo.h>

Servo cservo;

Servo fservo;

Servo tservo;

float coxaAngle = 90;

float coxaAngle2 = 122;

float angle;

float angle2;

float length;

float distance2 = 2.04;

float distance1 = 1.52;

float tibiaAngle;

float femurAngle;

void setup()

{

Serial.begin(9600);

cservo.attach(6);

fservo.attach(7);

tservo.attach(8);

}

void loop()

{

//Initial distance of foot from femur pivot point

//in first quadrant.

distance1 = 1.52;

//First quadrant calculations.

for(coxaAngle2 =122; coxaAngle2 >90; coxaAngle2--){

//Get angles based on foot distance from femur pivot point.

angle = atan(distance1/2.435);

length = 2.435/cos(angle);

angle2 = acos((9.20-length*length)/(-4*length));

//Get femur and tibia angles from above values.

femurAngle = 206-(angle + angle2) * 57.296;

tibiaAngle = 21.65 + acos(((length*length)-9.2)/-14.53) * 57.296;

cservo.write(coxaAngle2);

fservo.write(femurAngle);

tservo.write(tibiaAngle);

//Increment foot distance per degree of coxa servo rotation.

distance1 = distance1 + .016;

delay(100); //This will change based on needed speed later.

}

//Initial distance of foot from femur pivot point in

//second quadrant.

distance2 = 2.04;

//Second quadrant calculations.

for(coxaAngle =90; coxaAngle > 65; coxaAngle--){

//Get angles based on foot distance from femur pivot point.

angle = atan(distance2/2.435);

length = 2.435/cos(angle);

angle2 = acos((9.20-length*length)/(-4*length));

//Get femur and tibia angles from above values.

femurAngle = 206-(angle + angle2) * 57.296;

tibiaAngle = 206-acos(((length*length)-9.2)/-14.53) * 57.296;

cservo.write(coxaAngle);

fservo.write(femurAngle);

tservo.write(tibiaAngle);

//Increment foot distance per degree of coxa servo rotation.

distance2 = distance2 + .045;

delay(100); //This will change based on needed speed later.

}

}