How to control 2 servos at same time in sync? For overcoming torque issues, I have attached 2 identical servos on a certain part of my robot arm and because I saw someone do the same.

Now, while writing code I realize:

#include &lt;Servo.h&gt;
...
...
shoulder1.write(map(analogRead(p1), 0, 1023, 0, 179));
shoulder2.write(map(analogRead(p1), 0, 1023, 0, 179));
...


will turn shoulder1 by 20* and then shoulder2 by another 20*, ie. an overall turn of 40*; that too with too much load on servos, as the other servo would be inactive at the time first is active.

I want to achieve 20* fully-sync.ed turn on both servos, how do I accomplish this? Any arduino libraries or walkthrough?



Can I possibly move them both at the same time - something like multithreading on arduino? Here's what I tried:

void rotateTwoServoInSync(int angle) {
    for(int i = 0; i&lt;angle; i++) {
        shoulder1.attach(9);
        shoulder1.write(i);
        shoulder1.detach();
        shoulder2.attach(10);
        shoulder2.write(i);
        shoulder2.detach();
    }
}


Will it work? Is this approach recommendable?
If you have two RC servos that are always required to move together you can simply connect both control inputs to a single output.