SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By jayaneti
#115673
Hello, I am using a ardumoto, and have the program from sparkfun.
The program downloads using a serial cable, but it will not run without the serial cable being plugged in. I have a lithium backpack attached to it. I am using the Arduino Duemilanove. Please help. The code I am using is below:
//int pwm_a = 10; //PWM control for motor outputs 1 and 2 is on digital pin 10
int pwm_a = 3; //PWM control for motor outputs 1 and 2 is on digital pin 3
int pwm_b = 11; //PWM control for motor outputs 3 and 4 is on digital pin 11
int dir_a = 12; //direction control for motor outputs 1 and 2 is on digital pin 12
int dir_b = 13; //direction control for motor outputs 3 and 4 is on digital pin 13


void setup()
{
pinMode(pwm_a, OUTPUT); //Set control pins to be outputs
pinMode(pwm_b, OUTPUT);
pinMode(dir_a, OUTPUT);
pinMode(dir_b, OUTPUT);

analogWrite(pwm_a, 100); //set both motors to run at (100/255 = 39)% duty cycle (slow)
analogWrite(pwm_b, 100);

}

void loop()
{
digitalWrite(dir_a, LOW); //Set motor direction, 1 low, 2 high
digitalWrite(dir_b, LOW); //Set motor direction, 3 high, 4 low

delay(1000);

analogWrite(pwm_a, 255); //set both motors to run at 100% duty cycle (fast)
analogWrite(pwm_b, 255);

delay(1000);

digitalWrite(dir_a, HIGH); //Reverse motor direction, 1 high, 2 low
digitalWrite(dir_b, HIGH); //Reverse motor direction, 3 low, 4 high

delay(1000);

analogWrite(pwm_a, 100); //set both motors to run at (100/255 = 39)% duty cycle
analogWrite(pwm_b, 100);

delay(1000);
}
By esklar81
#115676
jayaneti,
I haven't proofread your code, but if the system does nothing without the USB cable attached, then it's probably a power problem, not a software problem. Here're a few things to investigate:
  1. How many cells are there in the "lithium backpack"?
  2. What voltage are you providing to the Ardumoto? That is, when you are trying to run it, what is the voltage across the battery connection terminals?
  3. What voltage is there on the Vin, 5V, and 3V3 pins of the Duemilanove, both with and without the USB cable attached?
  4. Does removing the motors change the behavior? That is, if you disconnect the motors, what happens when you try to run?
  5. Which way is the Ardumoto's voltage selection jumper set?


Happy Hunting,
Eric