BillHo:
Try this code (not tested)
/*
- Pololu High-Power Motor Driver 18v15 test program
Note: The pot is not directly controlling the motor,
but the Arduino is getting the value of the pot and
using PWM to control the motor speed based off of that value.
*/
int pot = 0; // analog A0
int Dir = 3; // Direction input
int motorPin = 11; // Pulse width modulation input
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set up Serial library at 9600 bps
pinMode(pot, INPUT);
pinMode(Dir, OUTPUT);
pinMode(motorPin, OUTPUT);
}
int getPot() {
int v;
v = analogRead(pot);
v = map(v, 0, 1023, 0, 255);
return v;
}
int motorFoward() {
analogWrite(motorPin, getPot());
delay(1000);
digitalWrite(motorPin, LOW);
delay(1000);
digitalWrite(Dir, HIGH);
Serial.println(getPot());
delay(1000);
}
int motorBackward() {
analogWrite(motorPin, getPot());
delay(1000);
digitalWrite(motorPin, LOW);
delay(1000);
digitalWrite(Dir, LOW);
Serial.println(getPot());
delay(1000);
}
void loop() // run over and over again
{
motorFoward();
motorBackward();
}
In the code you kindly shared with me on this thread, I was wondering what you the variables 'Dir' and 'MotorPin' are and how this should be wired? I can see that these two are output wires, but I don't know for sure where they are suppose to go.
This is the controller I am working with
Edit:
I have tried connecting Pin 11 on Arduino with PWM pin on Pololu. I have connected 'DIR' pin to pin 3 on Arduino. The 5V and Ground Pins on the Pololu have been connected to a 5v Power Source and a Ground. THE POT works PERFECTLY.When I turn the knob, different values printout on the screen correspondingly, so it has to be something to do with the Motor wiring.
On the other end of the Motor controller,I have connected a 9V battery into the inputs of the Pololu and a VEX motor into the Pololu 'OutA' and 'OutB'