Ardumoto Shield Kit Hookup Guide

This Tutorial is Retired!

This tutorial covers concepts or technologies that are no longer current. It's still here for you to read and enjoy, but may not be as useful as our newest tutorials.

View the updated tutorial: Ardumoto Kit Hookup Guide

Pages
Contributors: jimblom
Favorited Favorite 1

Introduction

The Ardumoto Shield is an easy-to-use dual motor controller for Arduino. Combined with an Arduino, the Ardumoto makes a fantastic controller platform for RC vehicles or even small autonomous robots.

Ardumoto

Ardumoto Shield assembled and situated on a RedBoard.

We sell the Ardumoto Shield either alone, or with a set of motors and wheels in our ArduMoto Shield Kit. This kit includes the Shield as well pairs of tires, motors, connectors, and wires. And, of course, it's all stuffed in a classic SparkFun red box (which may come in handy as a robot chassis).

ArduMoto Shield Kit

Contents of the Ardumoto Shield Kit.

Covered in this Tutorial

This tutorial covers assembly and use of both the Ardumoto Shield and the Ardumoto Shield Kit. Digging deeper, we'll get into some assembly tips, and finish with an example Arduino sketch.

The tutorial is split into sections covering:

If all you have is the shield, everything but the "Motor and Wheel Assembly" section will apply.

Required Tools & Materials

To follow along with this tutorial, you'll need an Ardumoto Shield or the Ardumoto Shield Kit, and an Arduino or Arduino-compatible development board.

Arduino Uno - R3

Arduino Uno - R3

DEV-11021
$27.60
138

SparkFun Ardumoto - Motor Driver Shield

DEV-09815
9 Retired

SparkFun RedBoard - Programmed with Arduino

DEV-12757
127 Retired

SparkFun Ardumoto Shield Kit

KIT-13201
1 Retired

Equipping the Ardumoto Shield (Non-kit version)

If all you have is the shield, you'll also probably want a couple of DC motors to drive. The Ardumoto can control most small DC motors, like any of those in our DC motor category.

You'll also need a handful of connectors to get everything wired up together. We recommend Stackable Headers to connect your Ardumoto to your Arduino. And two or three 3.5mm Screw Terminals to help connect motors to your Ardumoto.

As an example, here are the contents of the Ardumoto Shield Kit, which should be enough to get you started:

Powering the Shield

Both the Shield and the Kit will require a power source. Batteries are usually your best bet -- we recommend a 9V alkaline battery, which will work perfectly with the included 9V-to-Barrel Jack Adapter.

Required Tools

Finally you'll also need a few tools, including a soldering iron, solder, wire strippers, and a screwdriver:

Needle Nose Pliers

Needle Nose Pliers

TOL-08793
$3.50
1
Solder Lead Free - 15-gram Tube

Solder Lead Free - 15-gram Tube

TOL-09163
$3.95
4
Pocket Screwdriver Set

Pocket Screwdriver Set

TOL-12891
$4.50
5
Wire Strippers - 30AWG (Hakko)

Wire Strippers - 30AWG (Hakko)

TOL-12630
$12.87
3
Soldering Iron - 30W (US, 110V)

Soldering Iron - 30W (US, 110V)

TOL-09507
$10.95
7

Suggested Reading

The Ardumoto is a great platform for first-time motor users (and experienced ones too!). There are, however, a few concepts you should be familiar with before clicking over to the next few pages. Here are some tutorials we recommend reading first:

Meet the L298

At the heart of the Ardumoto -- the big, black chip right in the middle -- is an L298, one of our favorite dual-channel motor drivers around. On this page, we'll give you some background information on the chip we'll be depending on to drive our motors.

But First...Why a Motor Driver?

DC motors are the easiest motors to use. They're dumb (they don't provide feedback), but they're good at spinning in one direction or the other when we tell them to. Unlike servos or steppers, DC motors don't require any special signals -- just a straight DC voltage. So why can't we just connect them directly to the Arduino?

Well, motors tend to draw a lot of current, and trying to drive a motor straight from your Arduino output pins will make your Arduino quite cross with you. The Ardumoto lets you control a whole bunch of current (good for motors) with an itty-bitty signal (good for Arduinos). Everyone's happy!


Here are some of the important features and specifications of the L298. These extend out to be the specifications of the Ardumoto as well:

Two Channels @ 2A Each

The L298 is a two-channel motor driver. That means it can individually drive up to two motors. So it's perfect for a two-wheel drive vehicle, but if you have a special, four-wheel drive platform, you might need something else (or just two L298's).

Each channel on the L298 can deliver up to 2A to the motor to which it's connected. Keep in mind, though, that the amount of current available to your motor also depends on your system's power source. Batteries are great power sources because they're mobile, and can discharge a lot of current, but high current draw also means they'll drain faster.

The Control Signals

Controlling the L298 is very easy. If you've ever blinked or dimmed an LED, you already have all the tools necessary to control the L298.

For each of the L298's channels, there are two types of input we need to send to drive a motor: direction and enable. Each of these inputs are boolean -- either high or low.

Using the direction inputs, we can control whether the motor spins clockwise or counterclockwise. The L298 actually has two direction inputs for each channel, but on the Ardumoto, as we'll show on the next page, we've merged those two inputs into one.

The enable input can be driven either high or low to make the motor spin or stop. But, with pulse-width modulation (PWM), we can actually use this input to control the speed of our motor. Just like it can be used to dim LEDs, PWM is perfect for controlling how fast our DC motor spins.

All of the control signals are limited to a maximum of 7V. Which is great, because our Arduino is only going to supply a maximum of 5V.


That covers the basics of the L298. If you're curious, or want to know more about the chip, checking out the datasheet is a good place to start.

Ardumoto Overview

Before you get your soldering iron out, or start attaching motors, it'd be best if we briefly covered the basics of the Ardumoto Shield. On this page, we'll highlight the important inputs and outputs of the shield, so you can get a better idea of how you want to assemble it later.

Pins and Connectors

Here's an annotated view of the shield, highlighting the important pins and components:

Annotated

The Ardumoto Shield lays claim to four Arduino pins: 3, 11, 12, and 13. Each motor uses two pins -- one for direction, the other controls the speed.

Arduino PinArdumoto Shield Pin LabelNotes
3PWM AA PWM signal to control the speed of motor A. 0=off, 255=max speed.
11PWM BA PWM signal to control the speed of motor B. 0=off, 255=max speed.
12DIR AA digital signal to control the rotation direction of motor A (e.g. HIGH/LOW => CW/CCW).
13DIR BA digital signal to control the rotation direction of motor B (e.g. HIGH/LOW => CW/CCW).


While the Ardumoto Shield is attached to an Arduino, these pins shouldn't be connected to anything else.

Motor Outputs

Both of the L298's motor driver outputs are broken out to the left-edge of the shield. These 2-pin outputs are broken out to two footprints: a 3.5mm-pitch screw terminal and a 0.1"-pitch header. You can use either to wire up your motor, but screw terminals make life much easier if you need to disconnect your motor. The L298 is perfect for building simple 2 wheel drive robot platforms -- connect one motor to port A and the other motor to port B.

Using screw terminals on the Ardumoto shield

Technically, there is no right or wrong way to connect your motor's wires to the two output pins, but to help keep things straight, we suggest connecting the red / black wire for each motor to pins 1 / 2 on port A and pin 3 / 4 on port B, respectively.

Don't worry if you swap this, the direction control of the motor will just be swapped as well.

LED Indicators

Next to each of the motor outputs are a pair of blue and yellow LEDs, which indicate the direction your motor is spinning. These are great once you get to debugging your project. They're also useful if you want to test your sketch without wiring up any motors.

Supply Voltage

The Ardumoto Shield should be powered through one of two power supply inputs. Pick one or the other:

  1. The barrel jack input on the Arduino.
  2. The VIN input on the shield

If you don't want to use the Arduino's barrel jack input, you can use the VIN input on the shield instead. This voltage input will supply both the shield and the Arduino. Like the motor outputs, this connection is broken out to both a 3.5mm screw terminal and a 0.1"-pitch header.

Do not supply power to both the Arduino barrel jack input and VIN on the shield!

Spec'ing a Power Supply

Because VIN powers both your Arduino and your motors, you need to take extra care in deciding what you'll use to power your Arduino/Ardumoto combo. Not only does VIN have to fall within the acceptable range of your Arduino (usually 6-15V), but it also has to meet the specifications of your motor.

Check the voltage and current requirements of your motor before deciding how to power your Ardumoto project. These specifications vary. The 65RPM Hobby Gearmotors, for example, have a recommended range of 3-6V, but can be safely powered at up to 9V.

We recommend 9V Alkaline Batteries as an easy, if not-very-sustainable option. Dual-cell LiPo battery packs (7.4V nominal, 1000mAh capacity) are also a good option if you're looking for something mobile. A 9V wall wart can work if your project is stationary. For more help picking a power supply, check out our How to Power a Project tutorial.

Ardumoto Shield Assembly Tips

Before you can start using the Ardumoto Shield, you have to do a little assembly. Embrace your inner electronics technician and whip out that soldering iron! Time to turn a mish-mash of parts into a fully-functional 'duino shield!

Arduomoto parts list

On this page we'll go over some assembly tips. You don't have to follow these steps exactly -- assemble the shield as best fits your project's needs -- but this is good for general use of the shield.

Add Screw Terminals (Optional)

If you please, you can add screw terminals to both of the motor outputs and/or the VIN input.

If you're adding screw terminals to the motor outputs, slide them together first:

Screw terminals sliding together

Then insert them into the shield and solder.

Soldering screw terminals

Solder the Arduino Headers

To interface the shield with your Arduino, soldering male connectors to the 28 header pins is a must. Soldering ensures a reliable physical and electrical connection. If you've never soldered before, check out our through-hole soldering tutorial.

There are usually two options for connectors when you're assembling a shield: stackable or straight. We recommend stackable headers, because it allows you to stack other shields or jumper wires on top. The smaller male headers are a good option if you're looking for lower-profile installation.

If this is your first shield assembly, we recommend reading through our shield assembly guide. There are all sorts of tricks to installing shield headers, and making them look as good and straight as possible!

Shield assembly in progress

In the process of soldering stackable headers. Still a lot of pins to go!

Once you're done soldering the headers, plug the shield in to make sure everything fits cozily.

Headers installed

Prototyping Area

Let's address the elephant in the room. There's almost half-a-shield that we've failed to talk about thus far. The prototyping area! These rows and columns of 0.1"-spaced plated through-holes can be used to solder in all sorts of fun components.

You could add an accelerometer to enable bump detection in your robot. Or just fill it with LEDs to make your project as blinky as possible. Or, if you don't have any plans for the area, leave it be -- maybe you'll come up with something later.

Unlike other prototyping areas you may have encountered in the past, these holes are not wired together. You don't need to do any trace-slicing, but you will need to do some soldering and wire routing.

Motor and Wheel Assembly

This is where the shield assembly gets very project-specific. Have you picked out which motors you'll be driving with the shield? Do you know how long the wires need to be trimmed? There's a lot to be answered here before continuing on...

Wiring the Motors

If you have the kit, you already have a couple pairs of wires, but they still need to be stripped. Grab your Wire Strippers, and remove about 1cm of insulation from each end of each wire.

Wires stripped

Then it's time to solder the wires to your motors. Slide a black wire through the "eyelet" connector on a motor, then use a pair of pliers to crimp it around creating a decent mechanical connection.

Careful! The connectors on these motors are very delicate. Avoid stressing them or bending them any more than you have to. We highly recommend globbing each connector with some epoxy or hot glue after you've soldered them.

Wire crimped around motor connector

Then coat it with a warm blob of solder. Repeat the same set of steps for the red wire and the motor's opposite connector.

Motor wires soldered

Make sure the wires don't short on the motors nearby metal body.

Repeating the same set of steps on the other motor, try to match the positions of the red and black wires.

Both motors soldered

And make sure you don't yank the wires too hard now -- those motor terminals are rather delicate.

Connecting Motors

Connecting the motors to your shield is much easier -- especially if you have screw terminals. If you added screw terminals in the last step, break out your screw driver, slide the wires in, and tighten the terminals down

Motors connected to the shield

In lieu of screw terminals, you can solder the motor wires into either the 0.1" header or the screw terminal header.

Upcycling the SparkFun Box

If you have the Ardumoto Shield Kit, you probably also have a robust, resplendently red SparkFun box. These SparkFun boxes come in handy for all sorts of projects -- including robot chassis!

With some measured hobby knife incisions, you can cut out some mounts for the motors and tie your Arduino/shield combo down as well:

Ardumoto RedBox Bot

You may want to add a Ball Caster to the front, to keep the box from scraping against the floor. Now time to program the Arduino and make your RedBox-bot mobile.

Example Code

Controlling the Ardumoto Shield is super-easy. If you can blink LEDs, you can make the Ardumoto Shield spin its motors. Here, we'll provide a simple, expandable example sketch to show how to drive the pair of motors on the Ardumoto.

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.

If you have not previously installed an Arduino library, please check out our installation guide.

The Example Sketch

Download the example sketch and upload it to your board.

language:c
    /* Ardumoto Example Sketch
  by: Jim Lindblom
  date: November 8, 2013
  license: Public domain. Please use, reuse, and modify this 
  sketch!

  Three useful functions are defined:
    setupArdumoto() -- Setup the Ardumoto Shield pins
    driveArdumoto([motor], [direction], [speed]) -- Drive [motor] 
      (0 for A, 1 for B) in [direction] (0 or 1) at a [speed]
      between 0 and 255. It will spin until told to stop.
    stopArdumoto([motor]) -- Stop driving [motor] (0 or 1).

  setupArdumoto() is called in the setup().
  The loop() demonstrates use of the motor driving functions.
*/

// Clockwise and counter-clockwise definitions.
// Depending on how you wired your motors, you may need to swap.
#define CW  0
#define CCW 1

// Motor definitions to make life easier:
#define MOTOR_A 0
#define MOTOR_B 1

// Pin Assignments //
// Don't change these! These pins are statically defined by shield layout
const byte PWMA = 3;  // PWM control (speed) for motor A
const byte PWMB = 11; // PWM control (speed) for motor B
const byte DIRA = 12; // Direction control for motor A
const byte DIRB = 13; // Direction control for motor B

void setup()
{
  setupArdumoto(); // Set all pins as outputs
}

void loop()
{
  // Drive motor A (and only motor A) at various speeds, then stop.
  driveArdumoto(MOTOR_A, CCW, 255); // Set motor A to CCW at max
  delay(1000);  // Motor A will spin as set for 1 second
  driveArdumoto(MOTOR_A, CW, 127);  // Set motor A to CW at half
  delay(1000);  // Motor A will keep trucking for 1 second 
  stopArdumoto(MOTOR_A);  // STOP motor A 

  // Drive motor B (and only motor B) at various speeds, then stop.
  driveArdumoto(MOTOR_B, CCW, 255); // Set motor B to CCW at max
  delay(1000);  // Motor B will spin as set for 1 second
  driveArdumoto(MOTOR_B, CW, 127);  // Set motor B to CW at half
  delay(1000);  // Motor B will keep trucking for 1 second
  stopArdumoto(MOTOR_B);  // STOP motor B 

  // Now spin both!
  driveArdumoto(MOTOR_A, CW, 255);  // Motor A at max speed.
  driveArdumoto(MOTOR_B, CW, 255);  // Motor B at max speed.
  delay(1000);  // Drive forward for a second
  // Now go backwards at half that speed:
  driveArdumoto(MOTOR_A, CCW, 127);  // Motor A at max speed.
  driveArdumoto(MOTOR_B, CCW, 127);  // Motor B at max speed.
}

// driveArdumoto drives 'motor' in 'dir' direction at 'spd' speed
void driveArdumoto(byte motor, byte dir, byte spd)
{
  if (motor == MOTOR_A)
  {
    digitalWrite(DIRA, dir);
    analogWrite(PWMA, spd);
  }
  else if (motor == MOTOR_B)
  {
    digitalWrite(DIRB, dir);
    analogWrite(PWMB, spd);
  }  
}

// stopArdumoto makes a motor stop
void stopArdumoto(byte motor)
{
  driveArdumoto(motor, 0, 0);
}

// setupArdumoto initialize all pins
void setupArdumoto()
{
  // All pins should be setup as outputs:
  pinMode(PWMA, OUTPUT);
  pinMode(PWMB, OUTPUT);
  pinMode(DIRA, OUTPUT);
  pinMode(DIRB, OUTPUT);

  // Initialize all pins as low:
  digitalWrite(PWMA, LOW);
  digitalWrite(PWMB, LOW);
  digitalWrite(DIRA, LOW);
  digitalWrite(DIRB, LOW);
}

Then upload to your Arduino and watch your motors spin! If you want to dig really deep into the sketch, check out the comments.

Explaining the Sketch

For each motor there are two mechanisms we can control -- the direction of rotation and the speed. Each of those mechanisms is controlled by one pin on the Arduino.

Controlling Rotation Direction

We can only spin the motor in two directions -- clockwise or counter-clockwise -- so we only need two values -- 0 or 1 -- to control that from the Arduino. We can simply digitalWrite either of the direction pins (pin 12 for motor A, pin 13 for motor B) HIGH or LOW to go forward or backward.

For example, if you want motor A to spin clockwise, you simply need to digitalWrite pin 12 LOW:

language:c
digitalWrite(12, LOW);  // Motor A will spin clockwise

To make it spin the other way, write the pin HIGH.

language:c
digitalWrite(12, HIGH);  // Motor A will spin counter-clockwise

(Note: The rotation direction depends on how you wired the motor to your shield. If you swapped the red and black wires, the motor will spin opposite of how we've described here.)

Speeding

To control the speed of a motor we need to analogWrite to the PWM pins (pin 3 for motor A, pin 11 for motor B). A higher analogWrite value means a faster spin. Writing the pin LOW (or 0) will stop the motor.

PWM valueMotor Spin Speed
0Off (Stop)
127Half speed
255Full speed


If we want to turn motor A up to maximum speed, this is all we need:

language:c
analogWrite(3, 255);  // Motor A at max speed

After that line of code is executed, the motor will spin until stopped. To stop the motor, replace 255 with 0:

language:c
analogWrite(3, 0);  // Stop motor A

Don't forget to set your direction before spinning your motor!

Resources and Going Further

Resources

Going Further

  • HUB-ee Buggy Project - Build your own buggy using an Ardumoto shield.
  • Assembly Guide for RedBot -- If you're looking for a complete, beginner-level robotics platform, check out the RedBot Kit. It's Arduino-compatible, and the RedBot Mainboard has a motor driver built into it, so you don't even need an Ardumoto Shield.
  • Getting Started with the MiniMoto -- The MiniMoto is a more advanced, digitally-controlled, low-voltage DC motor driver. Great if you need a smaller form-factor motor controller.
  • How to Power a Project -- Batteries? Wall-warts? Solar? If you're not sure how to power your Ardumoto Shield project, take a trip over to this tutorial.

How to Power a Project

A tutorial to help figure out the power requirements of your project.

Assembly Guide for RedBot with Shadow Chassis

Assembly Guide for the RedBot Kit. This tutorial includes extra parts to follow to go along with the RedBot Inventor's Kit tutorial.