Instructables
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.

1-40 of 105Next »
xsalvador19 days ago

hi,

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.

Tranber7223 days ago

Hi

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

vsharma232 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..

F4X580IHYNYKYS9.RECTANGLE1.jpg
I am stuck with the same problem
RichardR31 month 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.

vsharma232 months ago
dudes2 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 dudes2 months ago

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

dudes dudes2 months ago

Oh and BTW, awesome instructable! Helped a ton.

blasterboy443 months ago

HI ALL....NEED HELP..THIS LOOKS LIKE THE HARDWARE I NEED..BUILDING A MODEL TRAIN TURNTABLE..WANTING TO PUT IN 10-16 STOPS CONTROLLED BY MOMENTARY PB..USING STEPPER MOTOR DIRECT CONNECTION..IT LOOKS LIKE THE ARDUINO AND MOTOR SHIELD ARE WHAT I NEED PLUS ???..TO CONTROL STOPS..SAY TO GO FROM NUMBER 6-10 .WITHOUT MAKING COMPLETE REVOLUTION..ANY HELP,I WOULD BE GREATFUL..THANKS RON..PS..I TYPE IN LARGE..EYES NOT SO GOOD..

stef80003 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?

cvbizz3 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

louisc24 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

TryChick4 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 phyu4 months ago

How to connect 2 or more motor shields??

pavan2345678 months ago

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.?

chris9111 year ago
How do i write the code to make a momentary switch, start the motor. Without having to hold down the switch?

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.

/*
Button

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:
const int buttonPin = 2; // the number of the pushbutton pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
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

}

1eaper chris91111 months ago

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 ?
shameet1 year ago
I have two stepper motors of these http://www.eminebea.com/en/product/rotary/steppingmotor/pm/highspeed/smw42s-48.shtml I have connected them on both the ends of a steel rod which is 5 mm diameter of length 50 cm Now i want turn the rod 45 degrees 1/4 turn when given a signal and back on signal Can some one help me with the code and the external power requirement for motor shield.
I am using this adafruit motor shield

http://www.adafruit.com/products/81

Adafruit Motor/Stepper/Servo Shield for Arduino kit - v1.2
This is exactly what I was looking for! I need to run a motor from a TIMER so that other code (serial commands) can be processed, so stripping your code down and reworking it into an ISR routine worked like a charm.

Thanks!

tt
Hi, I'm a motor shield newbie. I've got the R3 Motor Shield and old Uno. I'm trying to figure out which pins are not needed.

If I align it the way you showed in on your picture, I could see that 4 pins do not match the Arduino headers. These pins are SCL, SDA, IOREF, and the pin before IOREF. Is this correct?

Where you discouraging the cutting of the extra pins because they could be useful someday? I am thinking of just bending them a bit and insulating them to prevent shorts. Or just cut off a small bit of the pins. What would you suggest?

Thanks!
ground up1 year ago
Thanks for the help now I know what I need to build a robot and how to program it.
Radioshack is closing out these units for $2.50 each.
And they're now sold out.
The store I was at was in the process of shipping two back, but I was there just in time to buy them.
I am trying to control two motors, a servo, and a Ping sensor. am i able to connect the servo to one of the orange or white plugs to control it? or would i have to connect it normally to the arduino's pins
mikesevd1 year ago
Hello everyone!
I'm a new member and in arduino fun too (better late than never!). I've a couple of questions. Is the command myservo.attach(5 or 6) right when I connect a servo motor with the orange outputs of arduino motor shield? Since there are two ways to stick the three cables from a servo in that output, which one is the right one (should I use a voltmeter to find out?)? How can I use an extra power supply for a servo?
mike
johnmarc911 year ago
So, there are 6 plugs that I know is meant for Tinkerkit, I have regular motors, and would like to use them. I have found source code for controlling the tinkerkit, However that is only when using the Tinkerkit Motor shield. Anyone have any ideas for getting this to work?
holychachi1 year ago
I'm trying to come up with a way to control twelve steppers... Any ideas besides multiple driver boards?
shtranka1 year ago
i said what about connect two motor shields in one arduino card, and connect them ? can i have 12 * 2 v and 2* 2 A, is that doable !!
randofo (author)  shtranka1 year ago
I saw what you wrote. If they are 2.2 amps a piece, then you need a shield rated for at least 4.4 amps , and this shield can only handle 4 amps. That alone should indicate this shield is inappropriate. Typically you want a motor shield rated a fair amount above what your motor is rated for.

Also, you should figure out if you have two 12V motors or two 24V motors, because you have just said two different things.

From the link posted in the instructions above:

Summary
Operating Voltage 5V to 12V
Motor controller L298P, Drives 2 DC motors or 1 stepper motor
Max current 2A per channel or 4A max (with external power supply)
Current sensing 1.65V/A
shtranka1 year ago
if i have 2 DC motors 24v/2.2A each one can i use 2 motor shield with the same arduino card???
randofo (author)  shtranka1 year ago
You will need a larger motor controller for those. These shields can't really handle so much current.
THE STIG372 years ago
i am using the code given with dougstrickland's correction and i try to upload it and the motor isnt turning and i get an orange line of code at the bottom that says
avrdude: stk500_getsync(): not in sync: resp=0x00
I think that indicates an issue with the bootloader accepting your code. Can you run other code on it? Say, the blink code?

dman3 ringai1 year ago
what if the wheels aren't turning?
dman31 year ago
i uploaded this code but the wheels aren't turning...
any help?
1-40 of 105Next »