Im trying to create a somewhat autonomous car. I bought a smaller RC car from Radioshack, ripped out all the internal circuit board components, and am going to replace them with my arduino. I also bought this motor shied from Radioshack ->
http://www.ebay.com/itm/like/400778673527?lpid=82&chn=psMy RC car came with two motors built into it. One of them spins the back tires, while the other is used to steer the front tires. I ripped out the front motor for steering and replaced with small servo that i have. My Motor shield uses pins 8 - 13, and i have ultrasonic sensor hooked up to pins 6 and 7, with my servo connected to pin 5. I have no programming errors(that i know of). But after i compile my code, and upload it to the Arduino, my servo motor will tick, like its trying to do something, and my DC motor doesn't move at all.
When i comment out the code the set the servo to pin 5, the DC motor runs just fine. But when I have servo active, the DC motor doesn't run at all. If i unplug the Servo sensor pin(5), the dc motor still doesn't run at all.
So it seems when I do any kind of initialization of my Servo, the dc motors doesn't run.
here is an example of the first part of my code.
#include <MotorDriver.h>
#include <Servo.h>
#define servoPin 5
#define trigPin 6
#define echoPin 7
long duration, distance;
Servo myservo;
int pos = 0; //used to track where the servo is
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
//motor code for my Arduino Shield I got from Radio Shack
motordriver.init();
motordriver.setSpeed(200, MOTORB); //probably dont need this since i only have 1 motor connected.
motordriver.setSpeed(200, MOTORA); //setting up only one motor here, because the other set isn't used at all.
//servo motor used to steer
myservo.attach(servoPin); // attaches the servo on servoPin to the servo object
myservo.write(15); //sets the position of the servo so it always aligns the wheels straight
}
the rest of the code is just what to do with the information gotten from the ping sensor, probably not important, so i wont clutter up my post with it.
So my question is, does anyone have any ideas why the DC motor connected to the shield doesnt work when I initialize my servo?