Arduino uno + sensor shield + servos...help...

alright..i've got an arduino uno. two sensor shields and 18 servos...what i'm trying to do is program the arduino to work with the servos and make a mini hexabot. what i'm having some trouble with is the programming...where can i read the syntax reference for the servo library? and is there an example for mutiple servos? (and not just one?)

i'm also wondering if maybe there is a way to use the sd shield with the sensor shield and use the sd to hold the hex files to be called by a program running on the arduino?

Hi

Methods and examples for the servo library can be found here http://arduino.cc/en/Reference/Servo.

I’m a bit confused at your statement that you have two sensor shields. The sensor shield presents the Arduino digital and analog pins with power and GND pins alongside them so you can use standard connectors. There is no benefit in using two that I can think of.

For your example, I’ve taken the example “sweep” and added a 2nd, and tested it on a pan/tilt mech I have here with two servos. The following isn’t particularly useful, but shows how additional servos can be added.

#include <Servo.h> 
 
Servo myservo1;  // create servo object to control a servo 
Servo myservo2;  // and another 
 
void setup() 
{ 
  myservo1.attach(2);  // attaches the servo on pin 2 
  myservo2.attach(3);  // attaches this servo on pin 3
} 
 
 
void loop() 
{ 
  for(int pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo1.write(pos);              // tell servos to go to position in variable 'pos' 
    myservo2.write(pos);
    delay(10);                       // waits 10ms for the servo to reach the position 
  } 
  for(int pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo1.write(pos);              // tell servos to go to position in variable 'pos' 
    myservo2.write(pos);
    delay(10);                       // waits 10ms for the servo to reach the position 
  } 
}

Your 18 servos will hit the limit available to the Arduino directly, as it simply doesn’t have enough pins (you’ll also have to power them externally, but that’s covered in the page linked above) so you’ll need to come up with a way to get around that physical limitation. I’m sure there are heaps of examples out there, but it’s not something I’ve done.

Hope this helps some,
Geoff

the link helped..

the reason i got two is in case i manage to blow one out... but since i had it i though of using one on top of the other and controlling two identical servo movements with one pin signal...

i'm not 100% on if it will work...but i'm gunna see what i can come up with...

if the arduino uploader and my programming ever agrees with each other...

now i'm having trouble getting the program to upload my code... first it says that it won't compile because the file 'core.a' already exists... then when i get it to stop saying that it tells me com3 is already in use...but arduino is the only thing using it... then i solve that only to go back to the 'core.a' issue....