Arduino Usage

Install Adafruit Motor Shield V2 library

To use the shield on an Arduino, you'll need to install the Adafruit Motorshield v2 library. This library is not compatible with the older AF_Motor library used for v1 shields. However, if you have code for the older shield, adapting the code to use the new shield isn't difficult. We had to change the interface a little to support shield stacking, & we think its worth it!

To begin controlling motors, you will need to install the Adafruit_Motor_Shield_V2_Library library (code on our github repository). It is available from the Arduino library manager so we recommend using that.

From the IDE open up the library manager...

And type in adafruit motor to locate the library. Click Install

If you plan to use AccelStepper for acceleration control or for simultaneous control of multiple stepper motors, you will also need to download and install the AccelStepper library:

Running the Example Code

DC Motor

The library comes with a few examples to get you started up fast. We suggest getting started with the DC motor example. You can use any DC motor that can be powered by 6V-12VDC

First, restart the IDE to make sure the new library is loaded.

Plug the Wing into the Feather and connect a DC motor to Motor 1 - it does not matter which wire goes into which terminal block as motors are bi-directional. Connect to the top two terminal ports. See the photo below for the red and blue wire example. Be sure to screw down the terminal blocks to make a good connection!

You must also supply 5-12VDC to power the motor. You can power the Wing via a connected DC Barrel Jack as seen above. A battery pack is good for portable use. Note that this will not power the Feather, that's normal - you want to keep separate power supplies and the Feather is best powered by a separate lipoly battery

If the Green LED next to the power terminal block isn't lit up brightly do not continue!

Once you have verified the motor is connected properly and you have the power LED lit up brightly, we can upload our code.

In the IDE, load File->Examples->Adafruit_MotorShield->DCMotorTest

You should see and hear the DC motor turn on and move back and forth, attaching a slip of paper or tape as a 'flag' can help you visualize the movement if you have trouble seeing the movement

Stepper Motor Test


You can also test a stepper motor connection with the Wing. The wing can run unipolar (5-wire and 6-wire) and bipolar (4-wire) steppers. It cannot run steppers with any other # of wires! The code is the same for unipolar or bipolar motors, the wiring is just slightly different.

Plug the Wing into the Feather and connect a stepper motor to motor port 2 - unlike DC motors, the wire order does matter. Connect to the top two terminal ports (coil #1) and the bottom two terminal ports (coil #2).

  • If you have a bipolar motor, use all 4 pins
  • If you are using a unipolar motor with 5 wires, connect the common wire to GND on the power terminal block
  • If you are using a unipolar motor with 6 wires, you can connect the two 'center coil wires' together to GND on the power terminal block

You must also supply 5-12VDC to power the motor. You can power the Wing via a connected DC Barrel Jack as seen above. A battery pack is good for portable use. Note that this will not power the Feather, that's normal - you want to keep separate power supplies and the Feather is best powered by a separate lipoly battery

If the Green LED next to the power terminal block isn't lit up brightly do not continue!

Once you have verified the motor is connected properly and you have the power LED lit up brightly, we can upload our code.

In the IDE, load File->Examples->Adafruit_MotorShield->StepperTest

You should see and hear the stepper motor turn on and move back and forth, attaching a slip of paper or tape as a 'flag' can help you visualize the movement if you have trouble seeing the movement. There are four ways to move a stepper, with varying speed, torque and smoothness tradeoffs. This example code will demonstrate all four.

This guide was first published on Jul 29, 2016. It was last updated on Jul 29, 2016. This page (Arduino Usage) was last updated on Nov 19, 2019.