How to use a servo with a motor shield

Hi, I am new, so bear with me. I just got the arduino motor shield and a servo motor for a project. For the life of me, i can't find out how to use a servo motor while it is attached to the shield. All i want to know is how do you control a servo that is connected to the arduino motor shield

You don't use a standard servo with a motor shield. For a servo you connect one line to the power, one to the ground (make sure you have a common ground) and the control line to a digital pin one the Arduino.

Depending on the size of servo you may need a second power supply.

Mark

If you have this shield then this link has everything you need:
http://www.ladyada.net/make/mshield/

// Sweep
// by BARRAGAN <http://barraganstudio.com> 
// This example code is in the public domain.


#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
 
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  // Pin 9: Servo1
  // Pin 10: Servo2
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
}

jreeve17:
Hi, I am new, so bear with me. I just got the arduino motor shield and a servo motor for a project. For the life of me, i can't find out how to use a servo motor while it is attached to the shield. All i want to know is how do you control a servo that is connected to the arduino motor shield

As mentioned a hobby type R/C servo does not require a motor driver shield to operate, it's driver is built into the servo, but it does need access to an arduino digital output pin to control it.

So if whatever motor driver shield you have does not expose access to otherwise unused digital (pins the board doesn't use), then you have a rather sticky situation. Do you have a link to the specific motor controller shield you are talking about?

Lefty

Also note that using the Servo library on most boards will disable PWM output on pins 9 and 10. If that conflicted with your motor shield then combining a servo with motor control might be problematic.