Ardumoto Direction LED indication and

I've been trying to understand the Ardumoto behavior I'm seeing when I run the example sketch "Ardumoto_test_2".

I've run with a couple motors, and they turn, but not the way I'd expect, and one of them hardly turns at all.

I disconnected the motors just to figure out what the LEDs are telling me.

So my first question is: Can I run using USB power if I don't have any motors connected?
When I connect the arduino to external power I get the same results as below.

To test it and figure out what it's doing, I'm not connecting any motors and just watching the LEDs. This is ok, right?

  • The Ardumoto has blue and yellow LEDs to indicate direction, but - I never see the blue ones light at all.
  • The yellow LED on the left of the motor blocks is always yellow and seems to dim slightly when in slow speed.
  • The yellow LED on the right of the motor blocks goes on only when in the REVERSE direction and is off when in FORWARD.

Does this sound like the correct behavior?

When should I expect the blue LEDs to light?

Thanks,
Ed

It might help if you post your wiring diagram as well as the sketch...

There's no wiring diagram for this question: Just the Arduino and the Ardumoto shield.

Here's the sketch:

/*
6-29-10
Pete Dokter
SparkFun Electronics

This is an example sketch for Arduino that shows very basically how to control an Ardumoto
motor driver shield with a 5V Arduino controller board (3.3V may work, but it's out of spec
for the L298 H-bridge logic, so no promises). If you're plugging the Ardumoto into an
Arduino Duemilanove or similar, all the connections are done for you and you can just rewrite
the examples in this code to your liking.
*/

int pwm_a = 10; //PWM control for motor outputs 1 and 2 is on digital pin 10
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 = 3; //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);
Serial.println("Set SLOW");
Serial.begin(9600);
Serial.println("setup complete");
}

void loop()
{
digitalWrite(dir_a, LOW); //Set motor direction, 1 low, 2 high
digitalWrite(dir_b, LOW); //Set motor direction, 3 high, 4 low
Serial.println("lines for dir a and b set LOW to go FORWARD");
delay(3000);

analogWrite(pwm_a, 255); //set both motors to run at 100% duty cycle (fast)
analogWrite(pwm_b, 255);
Serial.println("set to FAST");
delay(3000);

digitalWrite(dir_a, HIGH); //Reverse motor direction, 1 high, 2 low
digitalWrite(dir_b, HIGH); //Reverse motor direction, 3 low, 4 high
Serial.println("lines for dir a and b set HIGH to go in REVERSE ");
delay(3000);

analogWrite(pwm_a, 100); //set both motors to run at (100/255 = 39)% duty cycle
analogWrite(pwm_b, 100);
Serial.println("SLOW speed");
delay(3000);
}

There's no wiring diagram for this question:

No that is silly.
There is say some wiring information in the schematic of the shield you are using and have not bothered posting a link to. Without knowing what arduino pin is connected to what chip input it is imposable to give a complete answer.
There is also the way you wired your motors power and ground together with the shield that make a difference as well.
There are two versions of your shield which are you using.

Next time you post code use the # button in the reply box.

Thanks for the reply. I'll try to provide as much detail as I can.

Here's the schematic for Ardumoto v13 dated 2/2010. Although I can't tell for sure which version I have. I just got it a few weeks ago, so I presume it's the latest one.

My arduino is the Duemilanove.

The Sparkfun Ardumoto: SparkFun Ardumoto - Motor Driver Shield - DEV-14129 - SparkFun Electronics

So, can you tell from the schematic and the code below when I can expect the blue LED to light when I'm running the sketch below without connecting to the motors up?

When I do connect the motors, they are 3-6v dc motors from this kit:

Example Sketch from ardumoto site here:
http://www.sparkfun.com/Code/Ardumoto_test_3.zip

/*
 6-29-10
 Pete Dokter
 SparkFun Electronics
 
 This is an example sketch for Arduino that shows very basically how to control an Ardumoto
 motor driver shield with a 5V Arduino controller board (3.3V may work, but it's out of spec
 for the L298 H-bridge logic, so no promises). If you're plugging the Ardumoto into an
 Arduino Duemilanove or similar, all the connections are done for you and you can just rewrite
 the examples in this code to your liking.
*/


int pwm_a = 10;  //PWM control for motor outputs 1 and 2 is on digital pin 10
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 = 3;  //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);
  Serial.println("Set SLOW");
 Serial.begin(9600);
 Serial.println("setup complete");
}

void loop()
{
 digitalWrite(dir_a, LOW);  //Set motor direction, 1 low, 2 high
 digitalWrite(dir_b, LOW);  //Set motor direction, 3 high, 4 low
   Serial.println("lines for dir a and b set LOW to go FORWARD");
 delay(3000);
 
 analogWrite(pwm_a, 255);  //set both motors to run at 100% duty cycle (fast)
 analogWrite(pwm_b, 255);
   Serial.println("set to FAST");
 delay(3000);
 
 digitalWrite(dir_a, HIGH);  //Reverse motor direction, 1 high, 2 low
 digitalWrite(dir_b, HIGH);  //Reverse motor direction, 3 low, 4 high
  Serial.println("lines for dir a and b set HIGH to go in REVERSE ");
 delay(3000);
 
 analogWrite(pwm_a, 100);  //set both motors to run at (100/255 = 39)% duty cycle
 analogWrite(pwm_b, 100);
  Serial.println("SLOW speed");
 delay(3000);
}

Thanks for the detail.

Yes you should expect the blue LED to come on when running that code and without any motors attached. If it is not then it looks like you have a faulty ardumoto and I would send it back.

Thanks for the reply.

I found one problem, and when I fixed it, I now see the blue led on one of the motors light up when in reverse.

The problem was in the code here where I must have changed dir_b accidentally from 13 to 3:

int pwm_a = 10;  //PWM control for motor outputs 1 and 2 is on digital pin 10
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 = 3;  //direction control for motor outputs 3 and 4 is on digital pin 13

should be:

int pwm_a = 10;  //PWM control for motor outputs 1 and 2 is on digital pin 10
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

And now one of the motors is behaving the way I'd expect, however the other one is not turning at all.

I'll have to dig some more on that one.

Thanks from an arduino noob,

Ed

Yikes! It appears that I may have damaged either one of the outputs of the ardumoto or both of my arduinos!

I've now tried both my Duemilanove and my Freetronics Twenty Ten (arduino compatible) and see the same behavior. That would point to the ardumoto, but I ran both boards with the ardumoto and the faulty code several times.

I'll have to think about whether using pin 3 as a direction output (accidentally) might lead to the behavior I'm seeing (one motor output failure)

I'll have to think about whether using pin 3 as a direction output

I wouldn't have thought so. Pin 3 is not connected to anything and just having it flapping about would have done no harm. Pin 13 gets initialised as an output anyway so that would not be a problem. I would say your board was faulty when you took delivery.

Solved the problem long ago but wanted to close the loop and be sure the solution was documented.

The defines for the pins were wrong. The correct ones for my ardumoto are :

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