Introduction: Adafruit Motor Shield Tutorial

Picture of Adafruit Motor Shield Tutorial

The Adafruit Motor Shield is a great and quick way to control DC motors, servos or even stepper motors. It has the capability of controlling up to 2 stepper motors, 4 DC motors. and 2 servos. I think this shield would be a good start for beginners because of its versatility for its price range.

Step 1: Basic Materials

Picture of Basic Materials

For this tutorial, there are some must-have:

1. An Arduino board (I'm using the Arduino Uno R3 but I think any versions would work)

2. Adafruit Motor Shield v1.0 (I got this one at a local store but I think it is also available on Amazon or other similar sites)

3. DC motors: I have a Tamiya double gearbox lying around so I'm going to use it as the motors.

4. Servos (optional): Just to demonstrate what the motor shield can also do

5. External power supply (optional): just in case your shield needs some extra juice

6. Breadboard, jumper wires

7. Arduino IDE, Processing, and the motor shield library (which I'm going to show you how to install it afterwards)

Step 2: Download the Library

Picture of Download the Library

First, download the library by clicking the link below.

https://github.com/adafruit/Adafruit-Motor-Shield-...

Uncompress the ZIP file onto your desktop (to make it easier)

Rename the uncompressed folder AFMotor. Be sure that there are the AFMotor.cpp and the AFMotor.h files in the AFMotor folder.

Go to My documents on your computer. Find the arduino library folder and put the AFMotor folder inside it.

Restart your Arduino IDE and check if you have a submenu called File -> Example -> AFMotor

If you can see the submenu, congratulation since you have successfully installed the shield's library.

If you can't see the submenu, check the steps above. If you still can't see it, look for a solution online from the manufacturer or from the site below.

https://learn.adafruit.com/adafruit-motor-shield/l...

Step 3: Installing the Shield Onto the Arduino

Picture of Installing the Shield Onto the Arduino

Pretty obvious. Stack the shield on top of the Arduino board. That's it!

Step 4: Connect the Motors and the Servos to the Shield

Picture of Connect the Motors and the Servos to the Shield

It looks a little bit complicated, isn't it?

But it's actually pretty simple if you look closely at the picture.

The black servo is connected to the SERVO_1 slot on the board while the blue one is connected to the SERVO_2.

The DC motor at the further corner (the one with red and purple wires) is connected to the M4 ports on the screw terminal block.

The DC motor next to it (the one with white and brown wires) is connected to the M3 ports on the screw terminal block.

So now the only terminal block that is left unused is the middle one (the ground one).

The positive end of the external power supply (the 9V battery) is connected to the +M terminal block on the board while the negative end is connected to the GND one. If the LED on the shield lights up, it means that the power input for the shield works.

Last thing, connect the Arduino to the computer for coding afterwards. I didn't do that in the picture but I think you can figure it out on your own.

We're almost there..

Step 5: Coding

Picture of Coding

I have included two separate codes in this instructables: one is for the Arduino IDE and the other is for Processing.

The Arduino code is used to control the board, while the Processing one is used for better visualization.

The Arduino board and the computer are connected through serial connection, so make sure you check the com port first.

And we are done!

Step 6: What's Next?

Picture of What's Next?

So this is an introduction for my next project in the near future: I'm going to build an internet-controlled telepresence robot based on this. I have already made some design and coding and I hope it will work.

If you have any questions, feel free to ask me. I will try my best to answer all of your questions.

Anyways thank you for checking out my instructables and I hope it will help you with your projects.

UPDATE: I have just finished the telepresence robot project so if you want to check it out, I included the link below.

https://www.instructables.com/id/Internet-Controlled-Telepresence-Robot/

Comments

Stonely0 (author)2017-08-24

hi just wanna say thank you for the great info here. I just make a purchase for this board after reading this and will be using your writeup for my learning. Wel done!

SiyuanY (author)2017-05-31

Love it! thanks! But what should I do if I have more than four motors? Like five?

JD74 (author)2017-05-26

can you add sensors or outputs like led and can you show me where to plug them by a picture

robopathshala (author)2017-03-11

does it supports pwm.

RamanathanS3 (author)2017-03-02

RS VASAN

I am a Hobbiest. I started using Aurduino and Adrafruit Motor Shield recently.

Thank you so much , this really helped me. Yet to try. I have every thing to complete. You are a very good teacher.Request you to help and do your best

to upgrade people's ( uanable to go to college )knowledge .Hats off

Ph222 (author)2016-12-08

Is it necessary to remove power jumper pin while connecting external power source to the motor drive shield? dose it work with 12V power suply safely?

TrungT4 (author)Ph2222017-02-26

Yeah the board works well with 12v power supply

Henbush8 (author)2016-12-14

I have a Due and aparantly the normal libraries don't work on it. Any suggestions?

TrungT4 (author)Henbush82017-02-26

I haven't tried on a Due board but I think more info can be found on the Adafruit website

https://learn.adafruit.com/adafruit-motor-shield/faq

tuilahuy made it! (author)2017-01-03

nice tutorial, thank you

TrungT4 (author)tuilahuy2017-02-26

You are welcome!!

czartony1 (author)2017-01-21

i love you guys

TrungT4 (author)czartony12017-02-26

Glad you like it

JohnO9 (author)2016-02-19

In your photo with everything hooked up I notice you didn't have power directly connected to the Arduino. Does it also get power from the Shield?

SanskarS6 (author)JohnO92016-11-19

the Arduino is powered from the computer through the USB cord , the shield can get its power fromArduino, using the jumper pins on the board when you only require 5v

shobhitd2 (author)2016-08-12

thank you so much !, this really helped me.

But can I connect other things to it(like sensors, etc) or to arduino??

If Yes, How can I do that because all my arduino pins are used by this motor shield??

please Help, Reply fast

SanskarS6 (author)shobhitd22016-11-19

some of the digital pins and none of the analog input pins used , to use them you could solder some pins on to the holes besides the respective pins ,or you could get yourself a arduino mega thats what iam using

nmsyahrian96 (author)2016-05-16

what if i add the irLed & phototransistor sensors (tcrt5000 in this case) and connect with the dc motors, like a micromouse robots, you got the code bro?

Rebelxxx (author)2016-01-26

One question. if motor shield is not broken, I suppose, i should see how it switching power for stepper ports, shouldn't I? I used AdaFruit library and stepper example, and used multimeter, but i saw no voltage on ports M1- M4. I think, my shield is DOA (dead on arrival).

TrungT4 (author)Rebelxxx2016-01-26

Yeah I think so. I had the same trouble with mine when I purchased it. I had to come back and trade for a new one. If you can't figure it out I suggest you do the same. Hope this helps.

Tytulaer (author)2015-12-06

Works perfectly. Thanks for the examples!

TrungT4 (author)Tytulaer2015-12-10

You are welcome. Check out my other instructables for the motor shield's actual application.

BradleyH2 (author)2015-11-02

import does not name a type?

JoesephM (author)2015-08-15

hey guys i try this code with one dc motor and it is worked good but i cant make it with 2 dc motor or more can any one write the code please

TrungT4 (author)JoesephM2015-10-29

You might need some extra power. Try to connect the shield to an external power supply.

Tanmay Deuskar (author)2015-10-27

Hello,

I want to make a robot which uses the Adafruit motor board and LDR. But how to connect LDR while the motor board is connected to the Arduino? The Analogue and digital pins are blocked. How to access them?

TrungT4 (author)Tanmay Deuskar2015-10-29

Hi,

It really depends on what pins you are using because some digital pins would be used if you are controlling certain motors or servos. The analog pins will not be used no matter what motors you want to control. There is a manual online that might help you determine which pins are in use when controlling specific motors. Hope that helps.

SurajS11 (author)2015-10-02

Can I control my Arduino motor shield trough a remote.I yes,then how can i control.

JoesephM (author)2015-08-14

hi guys i need help here with this shield can i conect Bluetooth module with this shield

TrungT4 (author)JoesephM2015-08-14

Hi Joseph,

I actually tried to add a HC-06 to this shield by getting the Tx and Rx wires under the shield in my telepresence robot project. It somewhat works I have to say, but if you are using certain motor outputs, these 2 pins might be interfered, and the device might not work as properly as you expected.

But if you are using an Arduino mega, chances are the Bluetooth module would work. I haven't tried it out myself, but since the board has multiple serial ports, it is capable of receiving Bluetooth signal while controlling the shield itself.

JoesephM (author)TrungT42015-08-15

thx bro

TrungT4 (author)2015-06-28

@cestes1: Thank you! It's great to see someone (besides my parents) interested in my future project. It means a lot for sure..

cestes1 (author)2015-06-28

So are you the future founder of Cyberdyne technologies. Good luck with your Skynet project there. ;-)

I'd be very interested to read about your next steps to creating your robot.

About This Instructable

75,668views

77favorites

Bio: Jumbo '21
More by TrungT4:3D Printed Robotic Blimp - It Flies, I Guess? Internet Controlled Telepresence Robot Adafruit Motor Shield Tutorial
Add instructable to: