Could you tell me what is wrong with this Arduino code?
Arrange your code like this:

Servo servo1, servo2;

void setup() {
    servo1.attach(41);
    servo2.attach(2);
}

void loop()
{
    int pos;

    for (pos = 0; pos &lt;= 180; pos++) {
        servo1.write(pos);
        delay(15);
        servo2.write(180 - pos);
        delay(15);
    }

    // 2nd loop here

}


It's rather inefficient to detach a servo after each write and then attach it again for the next write. Simply keep it up all the time.