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 $14.00 Add to Cart -
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 $1.95 Add to Cart -
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 WiFi Controlled Mobile Robot By M. Schwartz beginner All About Stepper Motors By Bill Earl beginner Improve Brushed DC Motor Performance By Jan Goolsbey intermediate Bluetooth Controlled Motorized Camera Slider By Ruiz Brothers beginner CircuitPython Hardware: PCA9685 DC Motor & Stepper... By Tony DiCola intermediate Adafruit Motor Selection Guide By Bill Earl beginner Improve the Low Speed of Brushed DC Motors By Jan Goolsbey intermediate 3D Printed Animatronic Robot Head By Rick Winscot 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 Adafruit FunHouse By M. LeBlanc-Williams beginner Adafruit H3LIS331 and LIS331 High-g 3-Axis... By Bryan Siepert beginner Your browser does not support the video tag. This links to the guide Adafruit 1.3" Color TFT Bonnet for Raspberry Pi. Adafruit 1.3" Color TFT Bonnet for Raspberry Pi By Kattni Rembor beginner Adafruit PiUART - USB Console and Power Add-on for... By lady ada beginner Adafruit PiCowbell Adalogger for Pico By Liz Clark beginnerCreate Wishlist
× Title Description Close Search SearchCategories
Tag » Arduino Motor Shield 4 Dc Motors Code
-
Arduino L293D Motor Driver Shield Tutorial
-
Controlling A DC Motor With Motor Shield Rev3
-
Control DC, Stepper & Servo With L293D Motor Driver Shield ...
-
Using L293D 4 DC Motors Shield For Arduino UNO And Mega
-
Arduino L293D Motor Driver Shield Tutorial : 8 Steps - Instructables
-
Control Several Motors With Motor Shield V1 And Arduino - AranaCorp
-
Control 4 DC Motor Using L293D DC Motor Sheidl For Arduino
-
Arduino's L293D Motor Driver Shield Guide - Engineers Garage
-
Arduino L293D Motor Driver Shield Control DC, Servo, And Stepper ...
-
Using DC Motors | Adafruit Motor Shield
-
L293D Motor Driver Shield For Arduino - MYTECTUTOR
-
[PDF] L293D Based Arduino Motor Shield
-
Quad DC Motor Driver Shield For Arduino - DFRobot
-
Arduino Motor Shield 4 Channel L293D H-Bridge Dc Motor Control ...
WiFi Controlled Mobile Robot By
All About Stepper Motors By
Improve Brushed DC Motor Performance By
Bluetooth Controlled Motorized Camera Slider By
CircuitPython Hardware: PCA9685 DC Motor & Stepper... By
Adafruit Motor Selection Guide By
Improve the Low Speed of Brushed DC Motors By
Adafruit H3LIS331 and LIS331 High-g 3-Axis... By
Adafruit PiCowbell Adalogger for Pico By