MEGA cant get to use more then 9 motors. (noob Questin)

I’m trying to take the first step and make a robot spider from ground up. Using 18 servo motors. So I had to get an arduino mega (1280)

I made a simple code to see if it was working but only the first 9 motors moved. Why?

I looked up the webpage and found out there is a mega lib. But can’t see if I have to have it or it’s just an old one, and the servo.h now covers it...
And I tried adding it to my script now then I get an error...

I’m new at the arduino and any help I can get will be a big ++

So simple. If I need the mega lib for this to work I will like to know what I have to change in my script for it to work :slight_smile: for the motors I have not used any pins that conflicts with the timers

#include <Servo.h>
// left front leg 1
Servo innerleg1;  
Servo middelleg1;
Servo outerleg1;
// left middel leg 2
Servo innerleg2;  
Servo middelleg2;
Servo outerleg2;
// left rear leg 3
Servo innerleg3 ; 
Servo middelleg3;
Servo outerleg3;
// right front leg 4
Servo innerleg4 ; 
Servo middelleg4;
Servo outerleg4;
// right middel leg 5
Servo innerleg5 ; 
Servo middelleg5;
Servo outerleg5;
// right rear leg 6
Servo innerleg6 ; 
Servo middelleg6;
Servo outerleg6;

/////////////////////////////////////////////////////////////////////////////



void setup() {
  // put your setup code here, to run once:


innerleg1.attach(26);
middelleg1.attach(24);
outerleg1.attach(22);

innerleg2.attach(25);
middelleg2.attach(23);
outerleg2.attach(28);

innerleg3.attach(31);
middelleg3.attach(29);
outerleg3.attach(27);

innerleg4.attach(38);
middelleg4.attach(37);
outerleg4.attach(39);

innerleg5.attach(34);
middelleg5.attach(35);
outerleg5.attach(36);

innerleg6.attach(30);
middelleg6.attach(33);
outerleg6.attach(32);
/////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////



pinMode(9, OUTPUT);


}

void loop() {
  // put your main code here, to run repeatedly: 



  
innerleg1.write(90);
middelleg1.write(90);
outerleg1.write(90);

innerleg2.write(90);
middelleg2.write(90);
outerleg2.write(90);

innerleg3.write(90);
middelleg3.write(90);
outerleg3.write(90);

innerleg4.write(90);
middelleg4.write(90);
outerleg4.write(90);

innerleg5.write(90);
middelleg5.write(90);
outerleg5.write(90);

innerleg6.write(90);
middelleg6.write(90);
outerleg6.write(90);

delay(5000);

innerleg1.write(45);
delay(500);
middelleg1.write(45);
delay(500);
outerleg1.write(45);
delay(500);
innerleg2.write(45);
delay(500);
middelleg2.write(45);
delay(500);
outerleg2.write(45);
delay(500);
innerleg3.write(45);
delay(500);
middelleg3.write(45);
delay(500);
outerleg3.write(45);
delay(500);
innerleg4.write(45);
delay(500);
middelleg4.write(45);
delay(500);
outerleg4.write(45);
delay(500);
innerleg5.write(45);
delay(500);
middelleg5.write(45);
delay(500);
outerleg5.write(45);
delay(500);
innerleg6.write(45);
delay(500);
middelleg6.write(45);
delay(500);
outerleg6.write(45);
delay(5000);
}

well it might be good to note that only pins 2-13 are PWM which is what most people think of when they hook up motors. umm if you just had the motors going straight off the arduino, your probably pulling too much power through ti for 1. if you could tell us how exactly you have your system setup it would be helpful. IE what shields if any, how the motors are hooked up.

I know that with an Uno, I've run 6 motors using 3 http://www.sparkfun.com/products/9479 chips (which i believe are the ones that are built into the arduino motorshield R3s correct?) and a TLC 5940 - PWM Driver - COM-10136 - SparkFun Electronics. just cause I wanted to see if you could multiplex motors (it was a fun adventure in fighting with code. CASE STRUCTURES, RAGE).

if a littel more was known about your setup though we'd probably be able to help better.

well it might be good to note that only pins 2-13 are PWM which is what most people think of when they hook up motors.

Servos don't need to be connected to PWM pins.

umm if you just had the motors going straight off the arduino, your probably pulling too much power through ti for 1. if you could tell us how exactly you have your system setup it would be helpful. IE what shields if any, how the motors are hooked up.

Yep. The most likely problem is that you are not powering the servos independently. The Arduino can not power servos. Period.

i will try for a bit more detail :slight_smile:

im using 18 futaba s3003 motors

i use from pin 22 to 39

i use a 600w pc powersupply (dit not have any other)

all running 6v (arduino from usb)

no shields pure arduino. (is that bad??)

http://youtu.be/Br_qCdL2sXw (movie when the script is running)

Are we really supposed to be able to follow that wiring?

im using 18 futaba s3003 motors

I'm not going to find a link. You should.

i use a 600w pc powersupply (dit not have any other)

At 6 volts, that should produce 100 Amps. Sounds pretty high to me. If only 9 motors work, they are drawing more than 11 Amps each, which seems very high.

Change the order of the code around. Do the same 9 servos work? Do the same 9 servos not work? Or, do the servos that work/don't work depend on the order that they are directed to move (i.e. the first 9 told to move, regardless of pin work, the others don't)?

i found the problem :slight_smile: or you did :wink: i needed to splid the motors in 2 power gropes so now they all work :slight_smile: many thx for making me look like a fool for not thinking of it :wink: hehe