Current warning: Do not exceed 1.2A peak per channel. For 4 motors running simultaneously, total current should stay below 2A to prevent L293D thermal shutdown.
The HW-130 is fully compatible with Adafruit’s AFMotor library.
Installation:
Download from Adafruit’s GitHub or via Arduino Library Manager (search “Adafruit Motor Shield”).
Example: Two DC motors
#include <AFMotor.h>AF_DCMotor motor1(1); // M1 AF_DCMotor motor2(3); // M3
void setup() motor1.setSpeed(150); // 0-255 motor2.setSpeed(200); motor1.run(FORWARD); motor2.run(BACKWARD);
void loop() motor1.run(FORWARD); motor2.run(BACKWARD); delay(2000); motor1.run(RELEASE); // stop motor2.run(RELEASE); delay(1000);
Stepper motor example:
#include <AFMotor.h>AF_Stepper stepper(48, 1); // 48 steps per revolution, motor port 1 (M1+M2)
void setup() stepper.setSpeed(30); // 30 rpm
void loop() stepper.step(100, FORWARD, SINGLE); delay(1000); stepper.step(100, BACKWARD, DOUBLE); delay(1000);
⚠️ Warning: Do not exceed 12V or 600mA per channel continuously.
// HW 130 with analogWrite() PWM speed control // Remove the ENA and ENB jumpers from the shield firstint ENA = 3; // PWM capable int ENB = 11; // PWM capable hw 130 motor control shield for arduino datasheet
void setup() pinMode(4, OUTPUT); // IN1 pinMode(5, OUTPUT); // IN2 pinMode(6, OUTPUT); // IN3 pinMode(7, OUTPUT); // IN4 pinMode(ENA, OUTPUT); pinMode(ENB, OUTPUT);
// Set direction forward for both motors digitalWrite(4, HIGH); digitalWrite(5, LOW); digitalWrite(6, HIGH); digitalWrite(7, LOW);
void loop() // Ramp up speed from 0 to 255 for (int speed = 0; speed <= 255; speed++) analogWrite(ENA, speed); analogWrite(ENB, speed); delay(10); delay(1000);
// Ramp down speed for (int speed = 255; speed >= 0; speed--) analogWrite(ENA, speed); analogWrite(ENB, speed); delay(10); delay(1000);
The HW 130 includes a current sensing circuit: a 0.5Ω resistor and a voltage divider. The output at CS A (Arduino A0) is approximately 0.5V per Ampere.
Formula: Motor Current (A) = (analogRead(A0) * (5.0 / 1023.0)) / 0.5 Current warning: Do not exceed 1
Practical Use: Detect stalls, measure load, or implement torque limiting.
int currentPin = A0; float voltage, current;void setup() Serial.begin(9600);
void loop() // Read current from Motor A voltage = analogRead(currentPin) * (5.0 / 1023.0); current = voltage / 0.5; // Because sensor is 0.5V/A Serial.print("Motor Current: "); Serial.print(current); Serial.println(" A"); delay(500);
Located at the bottom edge of the shield:
According to the standard L298P datasheet applied to the HW-130 board:
The HW 130 includes a 78M05 linear voltage regulator. This circuit is critical: The HW-130 is fully compatible with Adafruit’s AFMotor
Warning: Do not connect a 12V battery to Vs while JP1 is open. The 5V line will float, and your Arduino will not get logic power.