Servo Motor Initial Position (URGENT)

So I’m doing a robotic arm that has 4 servos. When I power on the breadboard and the arduino, the servos goes to a random position all of a sudden before starting the real code. I would like to remove this random positioning and I’m not sure how to do it.

This is the test code I’m using.

#include <Servo.h>

  Servo servo1,servo2,servo3,servo4;

void setup () {

servo1.attach(9);
servo2.attach(8);
servo3.attach(7);
servo4.attach(6);
}

void loop () {
  servo1.write(45);
    delay(1000);
  servo2.write(45);
    delay(1000);
  servo3.write(45);
    delay(1000);
  servo4.write(45);
    delay(1000);
    
  servo1.write(0);
    delay(1000);
  servo2.write(0);
    delay(1000);
  servo3.write(0);
    delay(1000);
  servo4.write(0);
    delay(1000);
    
}

If by "remove this random positioning" you mean that you want to specify the position that each servo starts in then just do a write(yourPos) immediately before each servo.attach().

BTW it's not actually random, it's the equivalent of doing a write(90) for each servo.

Steve

slipstick:
If by "remove this random positioning" you mean that you want to specify the position that each servo starts in then just do a write(yourPos) immediately before each servo.attach().

BTW it's not actually random, it's the equivalent of doing a write(90) for each servo.

Steve

Thank you Steve, that worked beautifully.

Regards,
Bruno.

Just to be pedantic!
In this case it’s a servo, NOT a servo motor...
The servo has a motor inside ir -with feedback, but there are many types of servo/servo motor.