Overview
Here is an excellent tutorial on how to control your DC motor using an H bridge:
http://itp.nyu.edu/physcomp/Labs/DCMotorControl
We have several Texas Instruments SN754410 available in the supply locker. This allows you to drive your motors without needing to cannibalize a servo.
Parts
-Arduino microcontroller and carrier board
-LiPo battery
-Motor
-SN754410 (data sheet)
-Jumper wires
Prepare the breadboard
Program the Microcontroller
#define switchPin = 2 // switch input#define motor1Pin = 12 // H-bridge leg 1 (pin 2, 1A)#define motor2Pin = 11 // H-bridge leg 2 (pin 7, 2A)#define enablePin = 9 // H-bridge enable pin#define ledPin = 13 // LEDvoid setup(){ // set the switch as an input: pinMode(switchPin, INPUT); // set all the other pins you're using as outputs: pinMode(motor1Pin, OUTPUT); pinMode(motor2Pin, OUTPUT); pinMode(enablePin, OUTPUT); pinMode(ledPin, OUTPUT); // set enablePin high so that motor can turn on: digitalWrite(enablePin, HIGH);}void loop(){ digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge high delay(2000); digitalWrite(motor1Pin, HIGH); // set leg 1 of the H-bridge high digitalWrite(motor2Pin, LOW); // set leg 2 of the H-bridge low delay(2000);}3. Dual Motor Driver Carrier
Pololu TB6612FNG driver (Data Sheet)
Prepare the breadboard
Program the Microcontroller
/*----------------------------------------------------------------Use PWM to drive a variable speed dc motor using an analog voltage to define the speed. Uses the Pololu TB6612FNG dual motor driver. Note: This is a first pass at coding for this chip: a) Can probably hardwire STBY high b) Could save a line since AIN1 and AIN2 are complements (Use a gate to invert) Derek Rowell 04/05/11 ---------------------------------------------------------------*/#define stbyPin 3 // STBY#define ain1Pin 4 // AIN1#define ain2Pin 5 // AIN2#define pwmaPin 6 // PWMA#define potPin 0 // Pot connected to analog in A0int Speed = 0;void setup(){ pinMode(stbyPin, OUTPUT); pinMode(ain1Pin, OUTPUT); pinMode(ain2Pin, OUTPUT); pinMode(pwmaPin, OUTPUT); digitalWrite(stbyPin, HIGH); digitalWrite(ain1Pin, LOW); digitalWrite(ain2Pin, LOW); }void loop(){ Speed = map(analogRead(potPin), 0, 1023, -255, 255); if (Speed > 0) { digitalWrite(ain1Pin, LOW); digitalWrite(ain2Pin, HIGH); analogWrite(pwmaPin, Speed); } else { digitalWrite(ain1Pin, HIGH); digitalWrite(ain2Pin, LOW); analogWrite(pwmaPin, abs(Speed)); } delay(50);}