The Adafruit Motor, Stepper & Servo Shield is a comprehensive motor control shield designed for use with the Arduino platform. This shield allows users to control up to 4 DC motors, 2 stepper motors, or 2 servos simultaneously. It is an ideal choice for hobbyists and engineers working on robotics, automation projects, or any application requiring motor control.
Pin | Function | Description |
---|---|---|
M1 | Motor 1 | Connects to DC Motor 1 or one coil of a stepper motor |
M2 | Motor 2 | Connects to DC Motor 2 or one coil of a stepper motor |
M3 | Motor 3 | Connects to DC Motor 3 or one coil of a stepper motor |
M4 | Motor 4 | Connects to DC Motor 4 or one coil of a stepper motor |
S1 | Servo 1 | Connects to Servo Motor 1 |
S2 | Servo 2 | Connects to Servo Motor 2 |
A0-A5 | Analog Inputs | Used for additional functionalities like sensors |
5V | Power | Supplies 5V to the shield from the Arduino |
GND | Ground | Common ground for the circuit |
#include <Adafruit_MotorShield.h>
#include <Wire.h>
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Connect a stepper motor with 200 steps per revolution to port #2
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);
void setup() {
AFMS.begin(); // Create with the default frequency 1.6KHz
myMotor->setSpeed(10); // Set the speed to 10 rpm
}
void loop() {
myMotor->step(100, FORWARD, SINGLE);
delay(500);
myMotor->step(100, BACKWARD, SINGLE);
delay(500);
}
Q: Can I control a 24V motor with this shield? A: No, the shield is designed for motors that operate between 5V and 12V.
Q: How many motors can I control with this shield? A: You can control up to 4 DC motors, 2 stepper motors, or 2 servos, but not all at the same time.
Q: Can I use this shield with Arduino Mega or other models? A: Yes, the shield is compatible with the Arduino UNO form factor, which is also present on other models like the Mega. However, you may need to adjust the code for different I/O pin assignments.