Using DC Motors | Adafruit Motor Shield V2
Maybe your like
- Overview
- FAQ
- Install Headers & Terminals
- Install Software
- Library Reference
- Arduino Library Docs
- Powering Motors
- Using RC Servos
- Using DC Motors
- Using Stepper Motors
- Python & CircuitPython
- Python Docs
- Stacking Shields
- Resources
- Single page
- Feedback? Corrections?
- Text View
-
Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit $19.95 Add to Cart -
Motor party add-on pack for Arduino $39.95 Add to Cart -
Stepper motor - NEMA-17 size - 200 steps/rev, 12V 350mA Out of Stock -
Small Reduction Stepper Motor - 5VDC 32-Step 1/16 Gearing $4.95 Add to Cart -
Small Reduction Stepper Motor - 12VDC 32-Step 1/16 Gearing $4.95 Add to Cart -
DC Toy / Hobby Motor - 130 Size Out of Stock -
Continuous Rotation Servo $11.95 Add to Cart -
Standard servo - TowerPro SG-5010 $12.00 Add to Cart
Using DC Motors
DC motors are used for all sort of robotic projects.The motor shield can drive up to 4 DC motors bi-directionally. That means they can be driven forwards and backwards. The speed can also be varied at 0.5% increments using the high-quality built in PWM. This means the speed is very smooth and won't vary!Note that the H-bridge chip is not meant for driving continuous loads of 1.2A, so this is for small motors. Check the datasheet for information about the motor to verify its OK!
Connecting DC Motors
To connect a motor, simply solder two wires to the terminals and then connect them to either the M1, M2, M3, or M4. Then follow these steps in your sketch
Include the required libraries
Make sure you #include the required libraries
Download File Copy Code #include <Wire.h> #include <Adafruit_MotorShield.h> #include "utility/Adafruit_MS_PWMServoDriver.h" #include <Wire.h> #include <Adafruit_MotorShield.h> #include "utility/Adafruit_MS_PWMServoDriver.h"Create the Adafruit_MotorShield object
Download File Copy Code Adafruit_MotorShield AFMS = Adafruit_MotorShield(); Adafruit_MotorShield AFMS = Adafruit_MotorShield();Create the DC motor object
Request the DC motor from the Adafruit_MotorShield:
Download File Copy Code Adafruit_DCMotor *myMotor = AFMS.getMotor(1); Adafruit_DCMotor *myMotor = AFMS.getMotor(1);with getMotor(port#). Port# is which port it is connected to. If you're using M1 its 1, M2 use 2, M3 use 3 and M4 use 4
Connect to the Controller
In your setup() function, call begin() on the Adafruit_MotorShield object:
Download File Copy Code AFMS.begin(); AFMS.begin();Set default speed
Set the speed of the motor using setSpeed(speed) where the speed ranges from 0 (stopped) to 255 (full speed). You can set the speed whenever you want.
Download File Copy Code myMotor->setSpeed(150); myMotor->setSpeed(150);Run the motor
To run the motor, call run(direction) where direction is FORWARD, BACKWARD or RELEASE. Of course, the Arduino doesn't actually know if the motor is 'forward' or 'backward', so if you want to change which way it thinks is forward, simply swap the two wires from the motor to the shield.
Download File Copy Code myMotor->run(FORWARD); myMotor->run(FORWARD);Page last edited July 09, 2013
Text editor powered by tinymce.
Using RC Servos Using Stepper Motors Related Guides Bluetooth Controlled Motorized Camera Slider By Ruiz Brothers beginner 3D Printed Animatronic Robot Head By Rick Winscot beginner Improve the Low Speed of Brushed DC Motors By Jan Goolsbey intermediate Adafruit Motor Selection Guide By Bill Earl beginner Your browser does not support the video tag. This links to the guide CurieBot: Arduino 101 Mini Robot Rover. CurieBot: Arduino 101 Mini Robot Rover By John Park beginner Motorized Camera Slider MK3 By Ruiz Brothers intermediate CircuitPython Hardware: PCA9685 DC Motor & Stepper... By Tony DiCola intermediate WiFi Controlled Mobile Robot By M. Schwartz beginner Improve Brushed DC Motor Performance By Jan Goolsbey intermediate All About Stepper Motors By Bill Earl beginner Your browser does not support the video tag. This links to the guide Introducing Feather RP2040 SCORPIO. Introducing Feather RP2040 SCORPIO By Phillip Burgess beginner Adafruit PyRuler By Kattni Rembor beginner Adafruit FONA By lady ada intermediate Your browser does not support the video tag. This links to the guide NES Emulator for Arcada. NES Emulator for Arcada By lady ada beginner Adafruit SEN54 or SEN55 Adapter Breakout By Liz Clark beginnerCreate Wishlist
× Title Description Close Search SearchCategories
Tag » Arduino Motor Shield V2 Example
-
[PDF] Adafruit Motor Shield V2
-
Control Several Motors With Motor Shield V2 And Arduino - AranaCorp
-
Adafruit Motor Shield V2 Library - Arduino Reference
-
Adafruit Motor Shield V2 - DC Motors - YouTube
-
Adafruit/Adafruit_Motor_Shield_V2_Library: V2! - GitHub
-
Control Motors Using Adafruit Motor Shield V2 - MathWorks
-
Motor Shield V2.0 - Seeed Wiki
-
Motor Control With Arduino And The Adafruit Motorshield V2 Board
-
Adafruit Motor Shield V2 Arduino Library: Adafruit_MotorShield ...
-
Adafruit Motor Stepper Servo Shield For Arduino V2 Kit
-
Adafruit Motor Shield Tutorial : 6 Steps - Instructables
-
Adafruit Motor Shield V2
-
Library Example: Adafruit_MotorShield : StepperTest - Codebender
-
Adafruit Motor/Stepper/Servo Shield For Arduino V2 - V2.3 Kit
Bluetooth Controlled Motorized Camera Slider By
Improve the Low Speed of Brushed DC Motors By
Adafruit Motor Selection Guide By
CircuitPython Hardware: PCA9685 DC Motor & Stepper... By
WiFi Controlled Mobile Robot By
Improve Brushed DC Motor Performance By
All About Stepper Motors By
Adafruit PyRuler By
Adafruit FONA By
Adafruit SEN54 or SEN55 Adapter Breakout By