Introduction: 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
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
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.
Step 3: 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
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
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?
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/
1 Person Made This Project!
- tuilahuy made it!
39 Comments
3 years ago
How to use this driver shield with Stm32f108t6 Bluepill in arduino ide software
Question 3 years ago
Hello
I would like information on the H-Bridge pin connections to the Arduino for M1, M2, M3, M4, Servo 1 and Servo 2. The support is appreciated. Kind regards
4 years ago
Don't have a clue of what to do. Downloaded both codes they opened 2 IDE's ?????
Question 4 years ago
I connecting adafruit motor shield to arduino, can my arduino damaged if i connect 12v to arduino 2.1 jack? because i only have a 12v adapter
Question 4 years ago
someone please help! my motor shield is not worked, how to fix them?
5 years ago
Love it! thanks! But what should I do if I have more than four motors? Like five?
Reply 4 years ago
I would suggest looking at Motor Drivers at Pololu Robotics. http://www.pololu.com Most of the drivers are capable of more current than the basic motor shield, and using the same code. Some have their own libraries because those controllers have extra features.
Question 4 years ago
hey, is there a way to hook up two stepper motors to this shield and then control them separately using two push buttons?
Question 5 years ago on Introduction
Hello
I can make a pgm for one motor start low en go faster till max 255,but i can not pgm the second also the 3 en 4 motor on the schield L293D ,
Whiring no problem but the code is my problem?
(Sorry for my englisch )(Dutch is my language)
regards Ghislain
5 years ago
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!
5 years ago
can you add sensors or outputs like led and can you show me where to plug them by a picture
6 years ago
does it supports pwm.
6 years ago
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
6 years ago
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?
Reply 6 years ago
Yeah the board works well with 12v power supply
6 years ago
I have a Due and aparantly the normal libraries don't work on it. Any suggestions?
Reply 6 years ago
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
6 years ago
i love you guys
Reply 6 years ago
Glad you like it
7 years ago
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?