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;