Problem Writing to multiple pins at one time , servos

I have 1 servo working. The code works fine when I am only using 1 servo. My problem is I want to control 4 servos at once, but only 1 servo will respond. I think the problem is my arduino will only write to ONE of the FOUR pins. Here is my code. All servos have been checked separately and work. Each pin/port works by itself. Furthermore, When I have 2 pins connected only 1 will work.

#include <Servo.h>
 
Servo esc1;
Servo esc2;
Servo esc3;
Servo esc4;
int throttlePin = A0;
 
void setup()
{
esc1.attach(2);
esc2.attach(3);
esc3.attach(4);
esc4.attach(5);
}
 
void loop()
{
int throttle = analogRead(throttlePin);
throttle = map(throttle, 0, 1023, 0, 179);

esc1.write(throttle);
esc2.write(throttle);
esc3.write(throttle);
esc4.write(throttle);
}

How are you powering these servos, they pull a lot of current if driven simultaneously.

They are connected directly to a 12v source of AA batteries. I thought it was possible the power source was too weak to handle more than 1 servo running simultaneously, so I tested that theory. I used only 1 pin from the arduino and used a breadboard to connect TWO servos to that single pin. Both servos worked correctly.

So in other words, if I just wanted to connect all 4 servos to 1 port on the arduino, it would work fine. The problem with that is I obviously want to be able to control the servos independently. I'm starting to think my arduino is defective in some way, or I am missing something.

Has the servo power supply got a common GND connection with the the Arduino ?

12V servos sound unusual. From the variable names I would guess that you aim to use ESCs, possibly on a quadcopter.

You are correct. These are actually ESCs connected to brushless motors. I didn't mention it because I am having this exact pin problem with a few other beginner projects I have been working on. For example: I was using a transmitter and trying to write a HIGH signal to multiple pins, and it would only write to 1 pin instead of 4. I have tried different pins. I have tried spacing out my connections on the board (ex pin 1, 4, 7,9....) but that didn't help.

Have you got a common ground for all the devices?

Yes there is a common ground. I'm going to the store to buy another arduino to see if that one will work.

I think the problem is my arduino will only write to ONE of the FOUR pins.

What ever is your problem it is not that.

I'm going to the store to buy another arduino to see if that one will work.

I bet you it will work / function in exactly the same way. Try and understand what is happening rather than blindly swapping out parts.

jakefeb3:
You are correct. These are actually ESCs connected to brushless motors.

Powering 4 ESCs from a stack of AA cells? That's really pushing your luck. Expect
peak current flows in the 10 to 40A range on starting all 4 simultaneously, LiPo batteries
are practically a necessity for these motors, they have winding resistances measured in
fractions of an ohm.

Trust us, Arduinos can drive 4 pins simultaneously from the Servo library, there is
some problem somewhere, a process of detection is needed to narrow down what's
happening - it doesn't help to hide pertinent facts (calling a BLDC+ESC a servo...), all
details could be relevant.

Some servo/pot test code that prints to the serial monitor to see what is going on.

//zoomkat dual pot/servo test 12-29-12
//view output using the serial monitor

#include <Servo.h> 
Servo myservoS1;
Servo myservoS2;

int potpinS1 = 0;  //analog input pin A0
int potpinS2 = 1;

int newvalS1, oldvalS1;
int newvalS2, oldvalS2;

void setup() 
{
  Serial.begin(9600);  
  myservoS1.attach(2);  
  myservoS2.attach(3);
  Serial.println("testing dual pot servo");  
}

void loop() 
{ 
  newvalS1 = analogRead(potpinS1);           
  newvalS1 = map(newvalS1, 0, 1023, 0, 179); 
  if (newvalS1 < (oldvalS1-2) || newvalS1 > (oldvalS1+2)){  
    myservoS1.write(newvalS1);
    Serial.print("1- ");
    Serial.println(newvalS1);
    oldvalS1=newvalS1;
  }

  newvalS2 = analogRead(potpinS2);
  newvalS2 = map(newvalS2, 0, 1023, 0, 179);
  if (newvalS2 < (oldvalS2-2) || newvalS2 > (oldvalS2+2)){  
    myservoS2.write(newvalS2);
    Serial.print("2- ");    
    Serial.println(newvalS2);
    oldvalS2=newvalS2;
  }
  delay(50); //slow down looping to better read serial monitor 
}

I have found the problem and solution. I just bought an official arduino uno board manufactured by arduino. The arduino that was causing the problems was a generic brand called OSEPP uno. I bought that brand out of Frys electronics thinking it was equivalent to an official arduino board. It is obviously not. The lesson learned is only buy official arduino boards.

My code works now and I can continue with my project. The AA batteries are just a temporary power source for testing purposes.