Running 2 Servos at the same time

I’m making a hexapod and want to make all 3 legs go through their routines at once. kinda new to arduino, and the tutorials online look kinda hard. any simple, down to earth explanations? the code for one leg routine is:
[#include <Servo.h>;
Servo servoOne;
Servo servoTwo;
void setup(){
servoOne.attach(52);
servoTwo.attach(54);
servoTwo.write(25);
servoOne.write(25);
servoTwo.write(90);
servoOne.write(90);
}
void loop(){
}]
ps-that may be a little rough, still working out the kinks

The servo.write() function tells the servo to get moving. It does NOT wait for the servo to get to where you told it to go. Any number of servos can be moving at the same time.

so if i cascade my 3 top leg servos at once, they'll all relitivley get to the same spot at the same time?

Actual_Dragon: so if i cascade my 3 top leg servos at once, they'll all relitivley get to the same spot at the same time?

NO. If they arrive at the same time it will be by accident. Think about it. If one servo has to move 10 degrees and another has to move 100 degrees you would expect the second one to take 10 times as long - even if it was moving fast and the total time was very short.

If you want coordinated movement you will need to break the move for each servo into several short movements and command each of them separately and with the time co-ordinated between the servos. To be honest I'm not sure if that would work very well for servos because they are not designed for speed control. Have a look at the code in the servo function in Several Things at a Time

...R

A hexapod has 6 legs. Don't you want all 6 legs to move at the same time? But you are starting in the right place, with a test to get 2 servos moving together.

In setup, just get the initial position written and attach. Do the movements inside of the loop. Do read and study Robin's tutorial.

A hexapod has 6 legs. Don't you want all 6 legs to move at the same time?

Surely not. What will it stand on whilst all 6 legs are moving ? It would seem more likely that it would stand on 3 legs whilst moving the other 3 then do the same with the roles reversed.

I had all 6 legs in motion all the time. 3 legs down, moving backward while the 3 legs up were moving forward.

If you picked up the body, each foot would move as if it were touching a point on a tank tread as it rolled.

vinceherman: A hexapod has 6 legs. Don't you want all 6 legs to move at the same time?

no then it fall over

Actual_Dragon: no then it fall over

Only if you move the center of gravity outside of the triangle defined by the 3 legs that are down. For my experiments, that never happened with the range of movement that was pretty much limited by the leg arrangement. This video was one of the first algorithms. We later smoothed out the end step. This was before we moved up to stronger hip servos for better weight bearing. My Hexapod

In order for it to move forward, the legs that are down must move backwards. While the legs are up in the air, they can do whatever you want. A rockette kick or the hokey pokey shake it all about. So long as they are down on the ground in time for the legs that were down to pick up.

Playing with different gates is fun. I implemented a 3 and 3 gate. 3 down, moving backwards with 3 up moving forwards to get to the start of their down portion of the cycle. But you can easily do a 5 and 1. With 6 legs down moving backwards slowly, one picks up and quickly jumps forward them back down, where it resumes the slow backwards pace. Then the next leg jumps up, forward and down and resumes the slow backwards pace. Repeat with the other 4 legs. It very SPOOKILY looks like a real spider creeping up on something. 4 and 2 is similar.