Strange behavior on multiple servos

Hi,

I am trying to Control Three different servos connected to my Arduino Uno using some examples of code from YouTube. As long as I only have one servo connected things is going perfect, but when I connect the second one, the servos starts to behave strange.

This is one example I have used:

#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
void setup() {

  • servo1.attach(9);*
  • servo2.attach(10);*
  • servo3.attach(11);*

}
void loop() {

  • servo1.write(45);*
  • servo2.write(45);*
  • servo3.write(45);*
    delay(1000);
  • servo1.write(90);*
  • servo2.write(90);*
  • servo3.write(90);*
    delay(1000);
    }

The problem is when I only have one servo connected to any of the ports (9,10,11) that one works perfect according to the code, but when I insert the second one both starts to really jitter, move really slow or not moving at all...

I have powered the Arduino with 5 v Power from a 220 v power trafo and USB Cable connected from a laptop all the time.

What could be the reason for that? Broken Arduino card, bad Power supply, faulty code...???

Regards,
Joakim B

I suggest look at the power supply design for your project. Do not try to power more than one small (9g) servo from the UNO. You need to power the servos with a separate regulated power supply, with adequate output power. You can look at the data sheet for your servo to see how many milliamps they need. The ground of the servo power supply and ground of the UNO should be connected together.

Note, when you post code in the forum please use code tags. See the How to Use This Forum sticky post near the top of the forum.

Thanks for fast reply!

The Power supply to the servos are separate, only the signal Cable (yellow one) is connected to the Arduino card. Supply to servos from trafo.

Is there any jumper which is supposed to be changed when Arduino Power supply comes from DC-Connection instead of USB Cable? Or does the Arduino take care of that automaticaly?

Arduino automatically selects best supply of voltage. The signal and ground of the servos must be connected to Arduino, so that means you must have a common ground.

j_bergstedt:
The Power supply to the servos are separate, only the signal Cable (yellow one) is connected to the Arduino card. Supply to servos from trafo.

I hope you have the Ground wire (black one) connected to the Arduino Ground. Without it the signal will have no reference.

I connected common ground and the servos started to do as supposed!

Thank you for your answers!