Picture of Arduino Motor Shield Tutorial
The Arduino Motor Shield allows you to easily control motor direction and speed using an Arduino. By allowing you to simply address Arduino pins, it makes it very simple to incorporate a motor into your project. It also allows you to be able to power a motor with a separate power supply of up to 12v. Best of all, the shield is very easy to find. Aside from being sold a number of places online, they are now stocked by most Radioshack stores. For all of these reasons, the Arduino Motor Shield if a cool little to have in your arsenal for rapid prototyping, and general experimenting.
Remove these adsRemove these ads by Signing Up

Step 1: Install

Picture of Install
The pins of the official Arduino motor shield will only align with Arduino Uno Rev. 3.

In order to make it work with older versions of the Arduino, you will need to trim a few pins off the motor shield. However, this is not, at all, recommended.

Insert the motor shield pins into the socket of the Arduino Uno.

Step 2: Shield Features

Picture of Shield Features
The motor shield has 2 channels, which allows for the control of two DC motors, or 1 stepper motor.

It also has 6 headers for the attachment of Tinkerkit inputs, outputs, and communication lines. The use of these pins is somewhat limited, and therefor not covered in this tutorial.

With an external power supply, the motor shield can safely supply up to 12V and 2A per motor channel (or 4A to a single channel).

There are pins on the Arduino that are always in use by the shield. By addressing these pins you can select a motor channel to initiate, specify the motor direction (polarity), set motor speed (PWM), stop and start the motor, and monitor the current absorption of each channel .

The pin breakdown is as follows:

Function Channel A Channel B
Direction Digital 12 Digital 13
Speed (PWM) Digital 3 Digital 11
Brake Digital 9 Digital 8
Current Sensing Analog 0 Analog 1

For more information about the technical specs, check out the motor shield's official page on the Arduino site.

Step 3: Program

Picture of Program
Plug the Arduino into your computer's USB port and open the Arduino development environment.

In order to get the board to do anything, you need to initialize the motor channel by toggling three parameters:
  1. First you need to set the motor direction (polarity of the power supply) by setting it either HIGH or LOW.
  2. Then you need to disengage the brake pin for the motor channel by setting it to LOW.
  3. Finally, to get the motor to start moving, you need to set the speed by sending a PWM command (analogWrite) to the appropriate pin.

If you do not do all three of these things, the motor will not turn on.

In the following steps are some common examples of common motor setups.

Step 4: One Motor

Picture of One Motor




Here is the code for controlling one motor:

Step 5: Two Motors

Picture of Two Motors
Interfacing with two motors is pretty much the same as interfacing with one motor. Simply plug the motor into Channel B.

The only difference code-wise is that you need to engage a second channel to control the second motor.

Here is code for controlling two motors:

Step 6: Stepper Motor

Picture of Stepper Motor
There are a number of different types of stepper motors, but in this tutorial we will specifically be addressing bipolar stepper motors. Bipolar stepper motors typically have 4 pins, which correspond to two coils. To use a stepper, you need to power these two coils in phase with alternating polarity.

To figure out which two pins make up a single coil, insert an LED into any two pins on its socket and rotate the motor shaft. If the LED lights up, you found one coil. The other two pins should make up the other coil.

To make a bipolar motor spin:
  1. Power the first coil.
  2. Next power the second coil with reverse polarity.
  3. Then power the first coil with reverse polarity.
  4. Finally, power the second coil.
To reverse the motor direction of a bipolar stepper, simply reverse the polarity of the second coil.

Here is code to make the stepper spin in one direction:

Here is code to make the stepper spin in the opposite direction:

1-40 of 121Next »
vsharma239 months ago

I m new in Arduino and i m trying to make. i m using this motor controler can you plz help me how to connect it with arduino and dc motor.??

plz reply..

I am stuck with the same problem

go to adafruit.com

Ofibro Ofibro1 month ago

it is theirs

For the stepper motor code, what is the difference between the two versions that makes them spin the motor in opposite directions? The two code sets look the same to me, but since I am just starting with this, I can easily be overlooking the critical difference. And is "delaylegnth" supposed to be "delaylength" (as I said, just starting, so I am not familiar with the syntax quirks). Thanks!
randofo (author)  firephotoputer3 years ago
delaylegnth is a variable, so it was defined (misspelled) by me. If you correct one instance of the spelling, just be sure to correct all of them in the code.

The difference between the two is the direction of Channel B in each of the codes. Look at the difference of sequence for: digitalWrite(13, HIGH); //Sets direction of CH B
Ofibro randofo1 month ago

hi great project


i have a problem with my external power supply

i tried everything, from disconnecting and connecting the bridge under the board right below the VIN pin i tried using a 9v jack i connected the 9v battery to the arduino's VIN pin directly.




to make matters worse, i bought another one yet still no use i borrowed two of them from my friend yet STILL no use


im deeply in need of you


P.S i know how to program it really good my problem lies on the power supply




Ofibro Ofibro1 month ago


just to the point of giving up I FINNALY got it.

all that it needed was amps.

I was using an lakline 9V battery which supplied 500mAh, which of course wasnt enough..

so i bought a couple of rechargeable batteries and VOLA it worked

keep in mind that those rechargeable batteries were 2200mAh @ 1.2 volts x5 so that was enough to get those motors moving!!

thanks anyways and great project.


Now that you have pointed it out, the difference between the versions is obvious. Thank you!
circitfied3 months ago

If your device requires more current and you are feeling rich you can just piggyback another motor shield on top and and join the connection block together.

blasterboy4410 months ago


You may try using "https://processing.org/" which is an advanced arduino based PDE file writing app. If you are up to the programming aspects it should be able to allow you to create what you need. larystoy@yahoo.com

Did you ever get it figured out? This is what I'm trying to do as well.

train459 [at] gmail

Podria alimentar el shield con 24 voltios para un canal a 2 amp para usar un solo motor. b_ playa1@hotmail.com muchas gracias
Train455 months ago

Does it matter what order you connect the two coils? What if you reverse the two wire to one of the coils, will it still work?

Train45 Train455 months ago

For that matter, how do you connect a uni-polar stepper? Where does the fifth wire go?

AR-OAR 15 months ago

I have a arduino motor shield, and I was using it with my arduino uno rev3.This birthday I bought a arduino mega 2560r3. So I just wanted to know if it would work with my shield

AR-OAR 15 months ago


What if i want to control 4 motors? what would be the possible solutions? thank you. :)

lezabour6 months ago

Hi there,

Thanks for this instructable, very good and clear

I have a problem with the power.

I have 2 motor, the arduino uno + motorshield v3

When i'm in USB, no need of external power, everything works.

If i put USB + shield external power ->

But as soon as i unplug USB, no matter what, nothing works:

9v External Uno + 9v external motor shield -> nothing happen

is there some specific wiring to do when using 2 external power supply?

Thanks again for your help

Tranber728 months ago


Do you have a solution and a code to control these two motors dc with an analog Joystick like http://www.robotshop.com/eu/fr/mini-capteur-manche...

Thank you for your help

I am also looking for a solution to this. Please let me know if you find out.


I find a system by software for can control one unipolar stepper motor using one Arduino Motor Shield R3

I use this and there are an example of 3 unipolar stepper motors using 3 Arduino Motor Shield R3 into my free APP "Arduino CNC Controller" I put instructions and pictures explain how to connect 3 boards, I use one Arduino Mega 2560 R3

Really there are 2 examples, the first example is using 3 bipolar stepper motors, that is normal example, and second example is using 3 unipolar/monopolar stepper motors.

Is free on Google Play: "Arduino CNC Controller"



This APP have a Window of "Help and documentation" in witch you can read this source code example.

Or you can download on:


xsalvador8 months ago


Thank you for that great tuto !

Could you please help me ? I made my own bot (2 sensors light to A3 and A4, 2 motors on A and N). It's ok and work fine. But as soon as i unplug usb cable, motor shield starts blinking (i tried 9V to the power of the shield, 12V too; i tried to plug a battery to the shield AND to the arduino... Nothing. Motors don't work. If i plug just one motor, that's ok. What could be the problem ? Is the shield broken ? It works fine with USB,..

Thanks for all that great stuff.

RichardR39 months ago

Thank you Sir Randofo!

This is what I really need, I hope you can also give us sample of 2 L293D and 4 motors running in one Arduino.

vsharma239 months ago
dudes9 months ago

I have a question, This code, delaylegnth = delaylegnth - 1, makes the delaylegnth decrease by 1 everytime the loop repeats. How would I make the delaylegnth decrease by .1?

dudes dudes9 months ago

Nevermind, i figured it out. Just use 'delayMicroseconds' instead of 'delay'

dudes dudes9 months ago

Oh and BTW, awesome instructable! Helped a ton.

stef800010 months ago

hello, can i have a code for 2 dc motor control? none of those i have works, how can i know that the shield works?

cvbizz10 months ago

I have the Arduino stacked with a motor shield and then a red bear blue tooth shield stacked on top of the motor shield. How do I get the blue tooth shield to talk to the motor shield? Thanks

louisc211 months ago

hi im new to motor shields and need some code so i came have two momentary buttons one to spin the motor one direction one the other direction

TryChick11 months ago

I'm using the Adafruit Ultimate GPS logger shield with the Arduino motor shield stacked on top with an Arduino Mega as my controller and have discovered I have some pin conflicts. This motor shield uses 3 pins (11, 12, 13) which the GPS shield also uses to read/write to the SD card which logs the GPS data. Any way to resolve this conflict or do I need to get a different shield which uses different pins to control the motors? I tried connecting the motors to different pins on the shield (instead of pin 11==>used pin 5, instead of pin 12==> used pin 4, instead of pin 13==> used pin 7) but the only thing that still works is the one pin I didn't change...pin 3 which controls the PWM of one side. so that motor works going forward and that is it.

amya phyu12 months ago

How to connect 2 or more motor shields??

My USB port connection is getting lost to the Arduino mega 2560 when i supply external current through an LED driver upto 1000mamp. I tried checking for 250ma and 350ma 0n the serial monitor by powering dc motors at 12v dc...it works fine but only at 1A and above the connection b/w usb port and controller is lost.

Kindly need suggestions to the earliest.?

chris9112 years ago

Hi there is sample code in the Arduin IDE for using a momentary switch. Here is my adaptation of it. Not sure if it actually works since I don't have an arduino handy.


The circuit:
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground

// constants won't change. They're used here to
// set pin numbers:

// variables will change:
int buttonPushed = 0; // button pushed variable. 0 means NOT PUSHED

void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);

while (buttonPushed =0){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// get out of this loop by setting the value of x to 1
x = 1

void loop(){

// your motor code goes here


I'm a newbie at the hardware, but from programming experience, I would say you need to make a boolean variable called running or something like that. Then when the button is pressed have an if statement that changes it to true if it is false and false if it is true. After that, only make the motor run when the variable is true.

Ok, apparently I am as lost as an easter egg. I need my stepper to move a certain number of degrees(steps) and stop. Then move a certain number back. I was under the impression that this is the advantage of a stepper... the fact that it STEPS. Why would I want to PWM a stepper when I could just use a regular DC motor?? I want it to do what it was designed to do, not dumb it down to be a regular motor.....

Tripou1 year ago
Hi there,

I'm a newbie on Arduino and I'd like to control a unipolar (6 wires) stepper motor with the rev3 shield. I've tried a few programs from myself and others but the m otor keeps making a sound without turning...
What I wantt to do first is making it turn on one way without stopping so that I can control its speed precisely.
Could anyone help me ?
1-40 of 121Next »