How to inverse gait quadruped?

hi forum!!!! the following code do sequences as follows
while coax steps backward the femur and tibia do up and down moves. when the coax reaches its backward end point it start to do forward step while femur and tibia do nothing
how to inverse those steps as follows ?
while coax steps backward the femur and tibia do nothing. when the coax reaches its backward end point it start to do forward step while femur and tibia do up and down steps

#include <Servo.h>
Servo sc3; // coax
Servo sf3; // femur
Servo st3;  // tibia


int i1L1 = 0;
int i2L1 = 0;
int i3L1 = 0;
int i4L1 = 0;

int speedV = 40;

void setup() {

 Serial.begin(9600);

sc3.attach(33);
sf3.attach(32);
st3.attach(31);

sc3.write(99);
sf3.write(55);
st3.write(72);

  delay(4000);
}
void loop() {

  moveLeg3();
    delay(speedV);
}


void moveLeg3() { 
//-----rise the leg
      if (i1L1 <= 7) {
    st3.write(60 + i1L1 * 2);
    sf3.write(55 + i1L1 * 3);
    i1L1++;
  }
  // rotate coax backward
  if (i2L1 <= 30) {
    sc3.write(100 + i2L1);
    i2L1++;
    }
     // step down the tibia
    if (i2L1 > 20 & i3L1 <= 10) {
    st3.write(90 - i3L1 * 2);
    sf3.write(87 - i3L1 * 3);// value 
    i3L1++;
  }
  // rotate coax forward
  if (i2L1 >= 30) {
    sc3.write(120 - i4L1);
    i4L1++;
  }

  if (i4L1 >= 30) {
    i1L1 = 0;
    i2L1 = 0;
    i3L1 = 0;
    i4L1 = 0;
  }
  }

thank you very much

Do you have a question?

a question usually has a question mark at the end :wink:

i am sorry for my bad writing form

that is my question

Add this code at the beginning of moveLeg3()

char buf[80];
sprintf(buf, "i1L1 = %2d i2L1 = %2d i3L1 = %2d i4L1 = %2d", i1L1, i2L1, i3L1, i4L1);
Serial.println(buf);

Post what you see on serial monitor. Do not post an image of serial monitor. Copy and paste from serial monitor into your post between code tags. Post enough lines that we can see the values all return to zero.

i1L1 =  0 i2L1 =  0 i3L1 =  0 i4L1 =  0
i1L1 =  1 i2L1 =  1 i3L1 =  0 i4L1 =  0
i1L1 =  2 i2L1 =  2 i3L1 =  0 i4L1 =  0
i1L1 =  3 i2L1 =  3 i3L1 =  0 i4L1 =  0
i1L1 =  4 i2L1 =  4 i3L1 =  0 i4L1 =  0
i1L1 =  5 i2L1 =  5 i3L1 =  0 i4L1 =  0
i1L1 =  6 i2L1 =  6 i3L1 =  0 i4L1 =  0
i1L1 =  7 i2L1 =  7 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 =  8 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 =  9 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 10 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 11 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 12 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 13 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 14 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 15 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 16 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 17 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 18 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 19 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 20 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 21 i3L1 =  1 i4L1 =  0
i1L1 =  8 i2L1 = 22 i3L1 =  2 i4L1 =  0
i1L1 =  8 i2L1 = 23 i3L1 =  3 i4L1 =  0
i1L1 =  8 i2L1 = 24 i3L1 =  4 i4L1 =  0
i1L1 =  8 i2L1 = 25 i3L1 =  5 i4L1 =  0
i1L1 =  8 i2L1 = 26 i3L1 =  6 i4L1 =  0
i1L1 =  8 i2L1 = 27 i3L1 =  7 i4L1 =  0
i1L1 =  8 i2L1 = 28 i3L1 =  8 i4L1 =  0
i1L1 =  8 i2L1 = 29 i3L1 =  9 i4L1 =  0
i1L1 =  8 i2L1 = 30 i3L1 = 10 i4L1 =  1
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  2
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  3
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  4
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  5
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  6
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  7
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  8
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  9
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 10
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 11
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 12
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 13
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 14
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 15
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 16
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 17
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 18
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 19
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 20
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 21
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 22
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 23
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 24
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 25
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 26
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 27
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 28
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 29
i1L1 =  0 i2L1 =  0 i3L1 =  0 i4L1 =  0
i1L1 =  1 i2L1 =  1 i3L1 =  0 i4L1 =  0
i1L1 =  2 i2L1 =  2 i3L1 =  0 i4L1 =  0
i1L1 =  3 i2L1 =  3 i3L1 =  0 i4L1 =  0
i1L1 =  4 i2L1 =  4 i3L1 =  0 i4L1 =  0
i1L1 =  5 i2L1 =  5 i3L1 =  0 i4L1 =  0
i1L1 =  6 i2L1 =  6 i3L1 =  0 i4L1 =  0
i1L1 =  7 i2L1 =  7 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 =  8 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 =  9 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 10 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 11 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 12 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 13 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 14 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 15 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 16 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 17 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 18 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 19 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 20 i3L1 =  0 i4L1 =  0
i1L1 =  8 i2L1 = 21 i3L1 =  1 i4L1 =  0
i1L1 =  8 i2L1 = 22 i3L1 =  2 i4L1 =  0
i1L1 =  8 i2L1 = 23 i3L1 =  3 i4L1 =  0
i1L1 =  8 i2L1 = 24 i3L1 =  4 i4L1 =  0
i1L1 =  8 i2L1 = 25 i3L1 =  5 i4L1 =  0
i1L1 =  8 i2L1 = 26 i3L1 =  6 i4L1 =  0
i1L1 =  8 i2L1 = 27 i3L1 =  7 i4L1 =  0
i1L1 =  8 i2L1 = 28 i3L1 =  8 i4L1 =  0
i1L1 =  8 i2L1 = 29 i3L1 =  9 i4L1 =  0
i1L1 =  8 i2L1 = 30 i3L1 = 10 i4L1 =  1
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  2
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  3
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  4
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  5
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  6
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  7
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  8
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  9
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 10
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 11
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 12
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 13
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 14
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 15
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 16
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 17
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 18
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 19
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 20
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 21
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 22
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 23
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 24
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 25
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 26
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 27
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 28
i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 29

Thanks for that. Can you modify like this and run again please?

char buf[80];
static int step = 0;
sprintf(buf, "Step %2d: i1L1 = %2d i2L1 = %2d i3L1 = %2d i4L1 = %2d", step++, i1L1, i2L1, i3L1, i4L1);
Serial.println(buf);

As I asked before, please use code tags. The formatting of what you posted has been lost, making it difficult to read because the columns do not line up. Edit your post and fix that please.

It seems that the patterns repeat after step 58, so you only need post steps 1 to 58.

Step  0: i1L1 =  0 i2L1 =  0 i3L1 =  0 i4L1 =  0
Step  1: i1L1 =  1 i2L1 =  1 i3L1 =  0 i4L1 =  0
Step  2: i1L1 =  2 i2L1 =  2 i3L1 =  0 i4L1 =  0
Step  3: i1L1 =  3 i2L1 =  3 i3L1 =  0 i4L1 =  0
Step  4: i1L1 =  4 i2L1 =  4 i3L1 =  0 i4L1 =  0
Step  5: i1L1 =  5 i2L1 =  5 i3L1 =  0 i4L1 =  0
Step  6: i1L1 =  6 i2L1 =  6 i3L1 =  0 i4L1 =  0
Step  7: i1L1 =  7 i2L1 =  7 i3L1 =  0 i4L1 =  0
Step  8: i1L1 =  8 i2L1 =  8 i3L1 =  0 i4L1 =  0
Step  9: i1L1 =  8 i2L1 =  9 i3L1 =  0 i4L1 =  0
Step 10: i1L1 =  8 i2L1 = 10 i3L1 =  0 i4L1 =  0
Step 11: i1L1 =  8 i2L1 = 11 i3L1 =  0 i4L1 =  0
Step 12: i1L1 =  8 i2L1 = 12 i3L1 =  0 i4L1 =  0
Step 13: i1L1 =  8 i2L1 = 13 i3L1 =  0 i4L1 =  0
Step 14: i1L1 =  8 i2L1 = 14 i3L1 =  0 i4L1 =  0
Step 15: i1L1 =  8 i2L1 = 15 i3L1 =  0 i4L1 =  0
Step 16: i1L1 =  8 i2L1 = 16 i3L1 =  0 i4L1 =  0
Step 17: i1L1 =  8 i2L1 = 17 i3L1 =  0 i4L1 =  0
Step 18: i1L1 =  8 i2L1 = 18 i3L1 =  0 i4L1 =  0
Step 19: i1L1 =  8 i2L1 = 19 i3L1 =  0 i4L1 =  0
Step 20: i1L1 =  8 i2L1 = 20 i3L1 =  0 i4L1 =  0
Step 21: i1L1 =  8 i2L1 = 21 i3L1 =  1 i4L1 =  0
Step 22: i1L1 =  8 i2L1 = 22 i3L1 =  2 i4L1 =  0
Step 23: i1L1 =  8 i2L1 = 23 i3L1 =  3 i4L1 =  0
Step 24: i1L1 =  8 i2L1 = 24 i3L1 =  4 i4L1 =  0
Step 25: i1L1 =  8 i2L1 = 25 i3L1 =  5 i4L1 =  0
Step 26: i1L1 =  8 i2L1 = 26 i3L1 =  6 i4L1 =  0
Step 27: i1L1 =  8 i2L1 = 27 i3L1 =  7 i4L1 =  0
Step 28: i1L1 =  8 i2L1 = 28 i3L1 =  8 i4L1 =  0
Step 29: i1L1 =  8 i2L1 = 29 i3L1 =  9 i4L1 =  0
Step 30: i1L1 =  8 i2L1 = 30 i3L1 = 10 i4L1 =  1
Step 31: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  2
Step 32: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  3
Step 33: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  4
Step 34: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  5
Step 35: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  6
Step 36: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  7
Step 37: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  8
Step 38: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 =  9
Step 39: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 10
Step 40: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 11
Step 41: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 12
Step 42: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 13
Step 43: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 14
Step 44: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 15
Step 45: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 16
Step 46: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 17
Step 47: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 18
Step 48: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 19
Step 49: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 20
Step 50: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 21
Step 51: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 22
Step 52: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 23
Step 53: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 24
Step 54: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 25
Step 55: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 26
Step 56: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 27
Step 57: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 28
Step 58: i1L1 =  8 i2L1 = 31 i3L1 = 11 i4L1 = 29
Step 59: i1L1 =  0 i2L1 =  0 i3L1 =  0 i4L1 =  0

i am sorry forget the code tag

To reverse that motion you will have to completely re-write the function. You have to figure out what each joint is doing at each step and run the steps backward.

Maybe you can replace the function with a table of positions. If you put this in the code you will get a comma-separated list of servo positions for each of the 58 steps. Then you can put those in a 2D array and play them back in any order.

char buf[80];
static int step = 0;
sprintf(buf, "{%d, %d, %d}, // Step: %02d ", sf3.read(), st3.read(), sc3.read, step++);
Serial.println(buf);

hi brother
i put your code in moveLeg3 function and get error said
error: invalid use of non-static member function 'int Servo::read()'

sprintf(buf, "{%d, %d, %d}, // Step: %02d ",sf3.read(), st3.read(), sc3.read, step++);

Looks like I forgot the '()' after the function name. I'm surprised you couldn't guess that by looking at the other two other function calls on the same line.

{55, 72, 99}, // Step: 00 
{55, 60, 100}, // Step: 01 
{58, 62, 101}, // Step: 02 
{61, 64, 102}, // Step: 03 
{64, 66, 103}, // Step: 04 
{67, 68, 104}, // Step: 05 
{70, 70, 105}, // Step: 06 
{73, 72, 106}, // Step: 07 
{76, 74, 107}, // Step: 08 
{76, 74, 108}, // Step: 09 
{76, 74, 109}, // Step: 10 
{76, 74, 110}, // Step: 11 
{76, 74, 111}, // Step: 12 
{76, 74, 112}, // Step: 13 
{76, 74, 113}, // Step: 14 
{76, 74, 114}, // Step: 15 
{76, 74, 115}, // Step: 16 
{76, 74, 116}, // Step: 17 
{76, 74, 117}, // Step: 18 
{76, 74, 118}, // Step: 19 
{76, 74, 119}, // Step: 20 
{87, 90, 120}, // Step: 21 
{84, 88, 121}, // Step: 22 
{81, 86, 122}, // Step: 23 
{78, 84, 123}, // Step: 24 
{75, 82, 124}, // Step: 25 
{72, 80, 125}, // Step: 26 
{69, 78, 126}, // Step: 27 
{66, 76, 127}, // Step: 28 
{63, 74, 128}, // Step: 29 
{60, 72, 120}, // Step: 30 
{57, 70, 119}, // Step: 31 
{57, 70, 118}, // Step: 32 
{57, 70, 117}, // Step: 33 
{57, 70, 116}, // Step: 34 
{57, 70, 115}, // Step: 35 
{57, 70, 114}, // Step: 36 
{57, 70, 113}, // Step: 37 
{57, 70, 112}, // Step: 38 
{57, 70, 111}, // Step: 39 
{57, 70, 110}, // Step: 40 
{57, 70, 109}, // Step: 41 
{57, 70, 108}, // Step: 42 
{57, 70, 107}, // Step: 43 
{57, 70, 106}, // Step: 44 
{57, 70, 105}, // Step: 45 
{57, 70, 104}, // Step: 46 
{57, 70, 103}, // Step: 47 
{57, 70, 102}, // Step: 48 
{57, 70, 101}, // Step: 49 
{57, 70, 100}, // Step: 50 
{57, 70, 99}, // Step: 51 
{57, 70, 98}, // Step: 52 
{57, 70, 97}, // Step: 53 
{57, 70, 96}, // Step: 54 
{57, 70, 95}, // Step: 55 
{57, 70, 94}, // Step: 56 
{57, 70, 93}, // Step: 57 
{57, 70, 92}, // Step: 58 
{57, 70, 91}, // Step: 59 
{55, 60, 100}, // Step: 60 
{58, 62, 101}, // Step: 61 
{61, 64, 102}, // Step: 62 
{64, 66, 103}, // Step: 63 
{67, 68, 104}, // Step: 64 
{70, 70, 105}, // Step: 65 
{73, 72, 106}, // Step: 66 
{76, 74, 107}, // Step: 67 
{76, 74, 108}, // Step: 68 
{76, 74, 109}, // Step: 69 
{76, 74, 110}, // Step: 70 
{76, 74, 111}, // Step: 71 
{76, 74, 112}, // Step: 72 
{76, 74, 113}, // Step: 73 
{76, 74, 114}, // Step: 74 
{76, 74, 115}, // Step: 75 
{76, 74, 116}, // Step: 76 
{76, 74, 117}, // Step: 77 
{76, 74, 118}, // Step: 78 
{76, 74, 119}, // Step: 79 
{87, 90, 120}, // Step: 80 
{84, 88, 121}, // Step: 81 
{81, 86, 122}, // Step: 82 
{78, 84, 123}, // Step: 83 
{75, 82, 124}, // Step: 84 
{72, 80, 125}, // Step: 85 
{69, 78, 126}, // Step: 86 
{66, 76, 127}, // Step: 87 
{63, 74, 128}, // Step: 88 
{60, 72, 120}, // Step: 89 
{57, 70, 119}, // Step: 90 
{57, 70, 118}, // Step: 91 
{57, 70, 117}, // Step: 92 
{57, 70, 116}, // Step: 93 
{57, 70, 115}, // Step: 94 
{57, 70, 114}, // Step: 95 
{57, 70, 113}, // Step: 96 
{57, 70, 112}, // Step: 97 
{57, 70, 111}, // Step: 98 
{57, 70, 110}, // Step: 99 
{57, 70, 109}, // Step: 100 
{57, 70, 108}, // Step: 101 
{57, 70, 107}, // Step: 102 
{57, 70, 106}, // Step: 103 
{57, 70, 105}, // Step: 104 
{57, 70, 104}, // Step: 105 
{57, 70, 103}, // Step: 106 
{57, 70, 102}, // Step: 107 
{57, 70, 101}, // Step: 108 
{57, 70, 100}, // Step: 109 
{57, 70, 99}, // Step: 110 

this the value i get

// f, t, and c positions for a step
const int STEPS_PER_GAIT = 60;
int steps[STEPS_PER_GAIT][3] =
{
  {55, 72, 99}, // Step: 00
  {55, 60, 100}, // Step: 01
  {58, 62, 101}, // Step: 02
  {61, 64, 102}, // Step: 03
  {64, 66, 103}, // Step: 04
  {67, 68, 104}, // Step: 05
  {70, 70, 105}, // Step: 06
  {73, 72, 106}, // Step: 07
  {76, 74, 107}, // Step: 08
  {76, 74, 108}, // Step: 09
  {76, 74, 109}, // Step: 10
  {76, 74, 110}, // Step: 11
  {76, 74, 111}, // Step: 12
  {76, 74, 112}, // Step: 13
  {76, 74, 113}, // Step: 14
  {76, 74, 114}, // Step: 15
  {76, 74, 115}, // Step: 16
  {76, 74, 116}, // Step: 17
  {76, 74, 117}, // Step: 18
  {76, 74, 118}, // Step: 19
  {76, 74, 119}, // Step: 20
  {87, 90, 120}, // Step: 21
  {84, 88, 121}, // Step: 22
  {81, 86, 122}, // Step: 23
  {78, 84, 123}, // Step: 24
  {75, 82, 124}, // Step: 25
  {72, 80, 125}, // Step: 26
  {69, 78, 126}, // Step: 27
  {66, 76, 127}, // Step: 28
  {63, 74, 128}, // Step: 29
  {60, 72, 120}, // Step: 30
  {57, 70, 119}, // Step: 31
  {57, 70, 118}, // Step: 32
  {57, 70, 117}, // Step: 33
  {57, 70, 116}, // Step: 34
  {57, 70, 115}, // Step: 35
  {57, 70, 114}, // Step: 36
  {57, 70, 113}, // Step: 37
  {57, 70, 112}, // Step: 38
  {57, 70, 111}, // Step: 39
  {57, 70, 110}, // Step: 40
  {57, 70, 109}, // Step: 41
  {57, 70, 108}, // Step: 42
  {57, 70, 107}, // Step: 43
  {57, 70, 106}, // Step: 44
  {57, 70, 105}, // Step: 45
  {57, 70, 104}, // Step: 46
  {57, 70, 103}, // Step: 47
  {57, 70, 102}, // Step: 48
  {57, 70, 101}, // Step: 49
  {57, 70, 100}, // Step: 50
  {57, 70, 99}, // Step: 51
  {57, 70, 98}, // Step: 52
  {57, 70, 97}, // Step: 53
  {57, 70, 96}, // Step: 54
  {57, 70, 95}, // Step: 55
  {57, 70, 94}, // Step: 56
  {57, 70, 93}, // Step: 57
  {57, 70, 92}, // Step: 58
  {57, 70, 91}, // Step: 59
};

#include <Servo.h>
Servo sc3; // coax
Servo sf3; // femur
Servo st3;  // tibia


int i1L1 = 0;
int i2L1 = 0;
int i3L1 = 0;
int i4L1 = 0;

int speedV = 40;

void setup()
{

  Serial.begin(9600);

  sc3.attach(33);
  sf3.attach(32);
  st3.attach(31);

  sc3.write(99);
  sf3.write(55);
  st3.write(72);

  delay(4000);
}
void loop()
{
  static int stepCount = 0;
  static int direction = 1;

  moveLeg3(direction);

  delay(speedV);

  if (i1L1 < 0 || i1L1 >= STEPS_PER_GAIT) // End of one step
  {
    stepCount++;
    if (stepCount >= 5)
    {
      direction *= -1;  // Reverse direction
      stepCount = 0;
    }
  }
}


void moveLeg3(int direction)
{
  if (i1L1 < 0 || i1L1 >= STEPS_PER_GAIT) // Start of new step
    i1L1 = 0;

  sf3.write(steps[i1L1][0]);
  st3.write(steps[i1L1][1]);
  sf3.write(steps[i1L1][2]);
  i1L1 += direction;
}

the coax stand still and i try to out put the all servo as follows

{55, 72, 99}, // Step: 00 
{99, 72, 99}, // Step: 01 
{100, 60, 99}, // Step: 02 
{101, 62, 99}, // Step: 03 
{102, 64, 99}, // Step: 04 
{103, 66, 99}, // Step: 05 
{104, 68, 99}, // Step: 06 
{105, 70, 99}, // Step: 07 
{106, 72, 99}, // Step: 08 
{107, 74, 99}, // Step: 09 
{108, 74, 99}, // Step: 10 
{109, 74, 99}, // Step: 11 
{110, 74, 99}, // Step: 12 
{111, 74, 99}, // Step: 13 
{112, 74, 99}, // Step: 14 
{113, 74, 99}, // Step: 15 
{114, 74, 99}, // Step: 16 
{115, 74, 99}, // Step: 17 
{116, 74, 99}, // Step: 18 
{117, 74, 99}, // Step: 19 
{118, 74, 99}, // Step: 20 
{119, 74, 99}, // Step: 21 
{120, 90, 99}, // Step: 22 
{121, 88, 99}, // Step: 23 
{122, 86, 99}, // Step: 24 
{123, 84, 99}, // Step: 25 
{124, 82, 99}, // Step: 26 
{125, 80, 99}, // Step: 27 
{126, 78, 99}, // Step: 28 
{127, 76, 99}, // Step: 29 
{128, 74, 99}, // Step: 30 
{120, 72, 99}, // Step: 31 
{119, 70, 99}, // Step: 32 
{118, 70, 99}, // Step: 33 
{117, 70, 99}, // Step: 34 
{116, 70, 99}, // Step: 35 
{115, 70, 99}, // Step: 36 
{114, 70, 99}, // Step: 37 
{113, 70, 99}, // Step: 38 
{112, 70, 99}, // Step: 39 
{111, 70, 99}, // Step: 40 
{110, 70, 99}, // Step: 41 
{109, 70, 99}, // Step: 42 
{108, 70, 99}, // Step: 43 
{107, 70, 99}, // Step: 44 
{106, 70, 99}, // Step: 45 
{105, 70, 99}, // Step: 46 
{104, 70, 99}, // Step: 47 
{103, 70, 99}, // Step: 48 
{102, 70, 99}, // Step: 49 
{101, 70, 99}, // Step: 50 
{100, 70, 99}, // Step: 51 
{99, 70, 99}, // Step: 52 
{98, 70, 99}, // Step: 53 
{97, 70, 99}, // Step: 54 
{96, 70, 99}, // Step: 55 
{95, 70, 99}, // Step: 56 
{94, 70, 99}, // Step: 57 
{93, 70, 99}, // Step: 58 
{92, 70, 99}, // Step: 59 
{91, 70, 99}, // Step: 60 
{99, 72, 99}, // Step: 61 
{100, 60, 99}, // Step: 62 
{101, 62, 99}, // Step: 63 
{102, 64, 99}, // Step: 64 
{103, 66, 99}, // Step: 65 
{104, 68, 99}, // Step: 66 

hi brother i try with this code
to start lift the femur and tibia at the end point of backward coax steps

      if (i1L1 > = 30) {
    st3.write(60 + i1L1 * 2);
    sf3.write(55 + i1L1 * 3);
    i1L1++;
  }

its works but dont know yet how to midfied this code

     // step down the tibia
    if (i2L1 > 20 & i3L1 <= 10) {
    st3.write(90 - i3L1 * 2);
    sf3.write(87 - i3L1 * 3);// value 
    i3L1++;
  }

to get the right time of down move of femur and tibia

Try this. I have not tested it, so if there is a problem, describe it in detail.

void moveLeg3(int direction) { 
  static int step = 0;
  //-----rise the leg
  if (step <= 7) {
    st3.write(60 + step * 2);
    sf3.write(55 + step * 3);
  }
  // rotate coax backward
  if (step <= 30) {
    sc3.write(100 + step);
  }
  // step down the tibia
  if (step > 20 & step <= 30) {
    st3.write(90 - (step-20) * 2);
    sf3.write(87 - (step-20) * 3);// value 
  }
  // rotate coax forward
  if (step >= 30) {
    sc3.write(120 - (step-30));
  }

  step += direction;
  if (step < 0) step = 58;
  else if (step > 58) step = 0;
}

Also, in loop() change the call to moveLeg3(+1); for forwards and moveLeg3(-1); for reverse.

Oops. That 3rd one should be sc3.write(). I'm surprised you couldn't figure that mistake out from the behavior.

thank you brother its work.
by the way i also post this link
at the time the post written the code burn 3 servo
until this time it burn 3 more servo
what your suggestion about that