Using PWM to drive a BaneBots Motor

Hello,

New guy here. I'm trying to use PWM on a Arduino Duemilanove to drive a motor using a BaneBots motor controller: Search BB-12-45 ESC to see what controller it is (they won't let me post links).

I have been using the PWM pin 9 with the analogWrite() command to try and change the direction of the motor. So far all I have managed to do is send the the motor backward and forward at fill power, but not at varying speeds. This only works when I use the servo library. I've also tried scaling the clock down and it's given me the same results.

What am I doing wrong? Here is part of my code. It's parts of a switch/case statement to test a character coming in through serial.

int motor1 = 9;

void setup() {

Serial.begin(9600);

pinMode(motor1, OUTPUT);

}

void loop() {

if (Serial.available() > 0) {
int inByte = Serial.read();

switch (inByte) {
case 'w':

analogWrite(motor1, 220); //should turn the motor forward
break;

case 's':

analogWrite(motor1, 64); //should turn the motor backward
break;

Here is some helpful information about the way the PWM pins work.

http://www.thebox.myzen.co.uk/Tutorial/PWM.html

The section about Other Uses may answer some of the questions and concerns you are having.

What am I doing wrong?

This:-

I have been using the PWM pin 9 with the analogWrite() command to try and change the direction of the motor

PWM should only be used to control the speed of the motor, you should apply it to the enable pin of your motor controller. The direction signal must be a solid logic level.