A Motor Hat is an add-on board designed for microcontrollers like the Raspberry Pi. It is used to control motors and typically includes motor driver chips, power supply connections, and interfaces for controlling multiple motors. This component is essential for robotics projects, automated systems, and any application requiring precise motor control.
Specification | Value |
---|---|
Operating Voltage | 5V - 12V |
Motor Channels | 2 or 4 (depending on model) |
Current per Channel | Up to 1.2A continuous |
Peak Current | 3A per channel (short duration) |
Communication | I2C |
Dimensions | 65mm x 56mm x 13mm |
Pin Name | Description |
---|---|
VIN | Power supply input (5V - 12V) |
GND | Ground |
SDA | I2C data line |
SCL | I2C clock line |
M1+ | Motor 1 positive terminal |
M1- | Motor 1 negative terminal |
M2+ | Motor 2 positive terminal |
M2- | Motor 2 negative terminal |
Pin Name | Description |
---|---|
M3+ | Motor 3 positive terminal |
M3- | Motor 3 negative terminal |
M4+ | Motor 4 positive terminal |
M4- | Motor 4 negative terminal |
Power Supply:
Motor Connections:
Microcontroller Interface:
Programming:
#include <Wire.h>
#include <Adafruit_MotorShield.h>
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Connect a DC motor to port M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
void setup() {
Serial.begin(9600); // Set up serial communication at 9600 baud
Serial.println("Adafruit Motorshield v2 - DC Motor test!");
AFMS.begin(); // Create with the default frequency 1.6KHz
myMotor->setSpeed(150); // Set the speed to 150 out of 255
myMotor->run(FORWARD); // Turn on the motor in forward direction
}
void loop() {
myMotor->run(FORWARD); // Run the motor forward
delay(1000); // Wait for 1 second
myMotor->run(BACKWARD); // Run the motor backward
delay(1000); // Wait for 1 second
myMotor->run(RELEASE); // Stop the motor
delay(1000); // Wait for 1 second
}
Motor Not Running:
Overheating:
I2C Communication Failure:
By following this documentation, users can effectively utilize the Motor Hat in their projects, ensuring reliable and efficient motor control.