Using an array to assign multiple servos' positions

Please note that I am a novice and do not have a whole lot of experience with arduino.

So I am trying to set the position of multiple servo motors to their designated positions. In order to make it more efficient, I am using a for loop and an array of positions. I am testing this concept with two servos before I test it with more. For some reason, none of the servos will go to their correct orientations. It was just working not too long ago. Here is the code:

#include <Servo.h>
Servo servos[2];
int positions[]={90,90};

void setup() {
  for (int i; i<2; i++){
    servos[i].attach(i+11);
  }
  for (int i; i<2; i++){
    servos[i].write(positions[i]);
  }
}

void loop() {
}

Here's a link to a picture of the circuit in case I did something stupid: IMG_1285.JPG - Google Drive

OP's image

It's hard to tell what's connected to what.
Better to draw out a circuit - clearly separating power sources etc...

REMEMBER you cannot supply the servo +V from the Arduino!
It looks like your power supply goes straight into the Arduino - then out to the breadboard.

The servos require more than the board can supply, an dit will becoem 'dirty' as the servos operate - hence must be isolated from the logic on the cpu board.

lastchancename:
hence must be isolated from the logic on the cpu board.

Okay... I'm going to end up using about 36 servos (I know, it's a lot) so do you have any recommendations for adequate power supplies?

Well, you'll need to ensure the GROUND / 0V are all common
Then possibly break the servos into groups (so the power supply isn't huge).

Let's agree we are talking about RC style servos.. !

Say... each group of six servos is connected to a *single power supply, while the control wire still goes back to the Arduino servo control pins.

  • the rating of each cluster power supply depends on the type of servos, and the current requirement (mA or A) for the cluster of (six) servos.

e.g. 6 servos x 1.5A = 9A supply
or 6 servos x 500mA = 3A supply

Note that servos can draw MORE power if they are under load or 'stalled'.

Alright cool. How would I change the current in each cluster?

Depending on the type of servos, and type of power supplies that you have available.
The simple calculations above make it easy.

Big servos most probably use more power (Volts x Amps)
Big power supplies get more expensive - hence the suggestion of clusters or groups that can be powered independently.

I'm going to end up using about 36 servos

How will you be controlling that many servos ?

The big question for the size of the PSU is, how many will move at the same time?

Remember RC servos will draw current when stopped - more if they are holding a load.

True, should have included that.

So, how many servo's will move at the same time and do servo's need to apply a holding force?

  for (int i; i<2; i++){
    servos[i].attach(i+11);
  }

The first part of a for loop is the initialization section. This statement says "Starting with i equal to whatever value is present in the memory address referenced by i, while i is less than 2, do something, and then increment i.

Surely, THAT is not what you intended. If it was, you should be pursuing other interests. A career as a programmer is not in your future.

Hehe -
I was looking past that.
There are more fundamental issues to be addressed!
Observation acknowledged!

I was looking past that.

When the compiler reports problems, where in the list do you start fixing things? I get better results when I start at the top. I fix one issue, and try again.

I look at code the same way. I see something obviously stupid, and I don't even read what the poster thinks the problem is.