Servo help for quadruped!

I built a quadruped and I’m having troubles making it move correctly. I have successfully made it go in a circle but not straight. I am using Arduinos servo library and I just need to know something. How do I make 2 servos sweep at the same time in opposite directions. I can use a for statement and make 2 sweep in the same direction, but that not what I need. :-\

How do I make 2 servos sweep at the same time in opposite directions.

Pretty simple, really. If you want one to go from 90 to 0, and the other to go from 0 to 90, it is not that difficult to see that if the loop index goes from 0 to 90, one servo follows the loop index, and the other follows 90 minus the loop index.

can you show me example code for that. I'm new to programing

Read the “How to use this forum” sticky at the top of the forum that tells you how to post code correctly in</> code tags.

Then use your new knowledge to show us your current code that sweeps 2 servos together and we’ll fix it to sweep in opposite directions. But it’s often as simple as - if you’re now doing write(x) to both servos you need to change one of them to write(180-x).

Steve

Steven33:
can you show me example code for that. I’m new to programing

for(byte pos = 0; pos<90; pos++)
{
   oneServo.write(pos);
   twoServo.write(90-pos);
}

Like I said, not exactly rocket science.

well sorry, I litterally just started programming and thanks :slight_smile: