The Arduino Motor Shield R3 is the simplest way to add motor control to your Arduino projects — plug it directly on top of an Arduino Uno, connect your motors and power supply, and you’re driving DC motors, stepper motors, or servo motors within minutes. Based on the L298P dual H-bridge driver, the official Arduino Motor Shield R3 handles up to 2 A per channel and 18 V motor voltage, making it suitable for robotics, automated mechanisms, CNC axes, and motorized project enclosures. This guide covers everything from hardware specs and wiring to complete code examples for DC and stepper motor control.
Table of Contents
- Arduino Motor Shield R3 Specifications
- Hardware Overview and Pin Mapping
- Power Supply Setup
- Driving DC Motors: Code and Examples
- Driving Stepper Motors
- Servo Motor Control
- Practical Projects
- Frequently Asked Questions
Arduino Motor Shield R3 Specifications
The official Arduino Motor Shield R3 (SKU ASX00004) uses the L298P H-bridge driver IC — the same architecture as the popular L298N module, but integrated onto a stackable Arduino shield footprint. Here are the key specifications:
| Specification | Value |
|---|---|
| Driver IC | L298P (dual H-bridge) |
| Motor Supply Voltage | 5 – 18 V |
| Logic Supply | 5 V (from Arduino) |
| Continuous Current / Channel | 2 A |
| Peak Current / Channel | 3 A (≤ 2 seconds) |
| PWM Frequency | Up to 64 kHz (software selectable) |
| Number of Channels | 2 DC motor channels (or 1 stepper) |
| Servo Outputs | 2 (on pins 9 and 10) |
| Current Sensing | Yes (analog pins A0, A1) |
| Thermal Protection | Yes (L298P built-in) |
| Form Factor | Arduino Uno / Mega shield (R3 connector) |
| Dimensions | 68.6 × 53.3 mm |
Hardware Overview and Pin Mapping
The Motor Shield R3 stacks directly on top of an Arduino Uno (or Mega). Understanding which Arduino pins are consumed by the shield is critical — you cannot use these pins for other purposes when the shield is installed:
Arduino Pins Used by Motor Shield R3
| Arduino Pin | Shield Function | Notes |
|---|---|---|
| D3 | Channel B PWM (speed) | Motor B speed control |
| D4 | Channel B Direction | Motor B direction |
| D7 | Channel B Brake | Motor B brake (HIGH = brake) |
| D8 | Channel A Brake | Motor A brake (HIGH = brake) |
| D9 | Servo 1 / Channel A PWM | Motor A speed control |
| D10 | Servo 2 | Second servo output |
| D11 | Channel A Direction | Motor A direction |
| D12 | Channel B Direction (alt) | Used with D4 |
| A0 | Channel A Current Sense | ~3.3 V/A analog readout |
| A1 | Channel B Current Sense | ~3.3 V/A analog readout |
Free pins for your own use: D0, D1 (UART), D2, D5, D6, D13, A2, A3, A4 (I2C SDA), A5 (I2C SCL). You still have I2C and several digital/analog pins available for sensors and displays.
Motor Terminals
The shield has two screw terminal blocks on the top edge:
- Channel A terminals: A+ and A– → connect your first motor
- Channel B terminals: B+ and B– → connect your second motor
- External power terminals: PWR and GND → your motor supply voltage (up to 18 V)
- SERVO power header: 3-pin header for servo power (optional external supply)
Power Supply Setup
The Motor Shield R3 separates logic and motor power. The Arduino is powered via its USB or barrel jack as normal. The motors are powered from the External Power terminal on the shield.
Powering the Shield Correctly
- Remove the PWR jumper on the Motor Shield (the blue jumper between VIN and VIN Motor) — this isolates motor power from Arduino power
- Connect your motor supply (e.g., 12 V battery or adapter) to the shield’s PWR and GND screw terminals
- Power the Arduino separately (USB or 9 V barrel jack)
If you leave the PWR jumper installed: Motor power feeds the Arduino Vin pin. This can power the Arduino from the motor supply but creates a risk of voltage spikes damaging the Arduino 5 V regulator. Only leave it connected if your motor supply is ≤12 V and you’re not using motors with high startup current draws.
Minimum motor voltage: 5 V is the minimum. Standard 5V DC motors work but the L298P has a ~1.4 V drop across the H-bridge, so effective motor voltage is motor_supply – 1.4 V. For 5 V motors, use at least 7 V motor supply for full speed.
Driving DC Motors: Code and Examples
Direct Register Control (No Library)
You can drive the Motor Shield R3 with direct digitalWrite and analogWrite calls — no library needed:
// Motor Shield R3 - Direct Control
// Channel A: PWM=9, DIR=11, BRAKE=8
// Channel B: PWM=3, DIR=4, BRAKE=7
void motorA_forward(int speed) {
digitalWrite(8, LOW); // Brake OFF
digitalWrite(11, HIGH); // Direction: forward
analogWrite(9, speed); // Speed: 0-255
}
void motorA_reverse(int speed) {
digitalWrite(8, LOW);
digitalWrite(11, LOW); // Direction: reverse
analogWrite(9, speed);
}
void motorA_brake() {
digitalWrite(8, HIGH); // Brake ON
analogWrite(9, 255); // Full power to brake
}
void motorA_coast() {
digitalWrite(8, LOW);
analogWrite(9, 0);
}
void motorB_forward(int speed) {
digitalWrite(7, LOW);
digitalWrite(4, HIGH);
analogWrite(3, speed);
}
void motorB_reverse(int speed) {
digitalWrite(7, LOW);
digitalWrite(4, LOW);
analogWrite(3, speed);
}
void setup() {
pinMode(3, OUTPUT); // PWM B
pinMode(4, OUTPUT); // DIR B
pinMode(7, OUTPUT); // BRAKE B
pinMode(8, OUTPUT); // BRAKE A
pinMode(9, OUTPUT); // PWM A
pinMode(11, OUTPUT); // DIR A
Serial.begin(9600);
}
void loop() {
// Ramp up Motor A forward
for (int s = 0; s <= 255; s += 5) {
motorA_forward(s);
delay(20);
}
delay(1000);
motorA_brake();
delay(500);
// Ramp up Motor A reverse
for (int s = 0; s <= 255; s += 5) {
motorA_reverse(s);
delay(20);
}
delay(1000);
motorA_brake();
delay(500);
// Read current (Channel A on A0)
int raw = analogRead(A0);
float current_A = raw * (5.0 / 1023.0) / 3.3; // ~3.3V/A
Serial.print("Motor A current: "); Serial.print(current_A); Serial.println(" A");
}
Speed Control with Encoder Feedback
For precise speed control, add a motor encoder (hall effect or optical) and implement a simple PID controller. Connect encoder output to Pin 2 (INT0) for interrupt-driven pulse counting:
volatile long encoder_count = 0;
long last_count = 0;
unsigned long last_time = 0;
float rpm = 0;
const int PPR = 20; // Pulses per revolution (encoder spec)
void encoder_ISR() {
encoder_count++;
}
void setup() {
// ... motor pin setup as above ...
attachInterrupt(digitalPinToInterrupt(2), encoder_ISR, RISING);
Serial.begin(9600);
}
void loop() {
unsigned long now = millis();
if (now - last_time >= 500) { // Calculate every 500ms
long delta = encoder_count - last_count;
rpm = (delta / (float)PPR) * (60000.0 / (now - last_time));
last_count = encoder_count;
last_time = now;
Serial.print("RPM: "); Serial.println(rpm);
}
motorA_forward(200); // Constant PWM for now, add PID here
}
Driving Stepper Motors
The Motor Shield R3 can drive one bipolar stepper motor using both channels A and B. Connect the two coil pairs: one coil pair to Channel A terminals, the other to Channel B terminals.
Stepper Motor Wiring
- 4-wire bipolar stepper: Coil 1 → A+/A–, Coil 2 → B+/B–
- 6-wire unipolar stepper: Use only 4 of the 6 wires (the two common wires are left unconnected for half-winding use, or connected together to motor supply for full winding)
Stepper Code (Full Step)
#include <Stepper.h>
// Steps per revolution for your motor (check datasheet)
const int STEPS_PER_REV = 200; // 1.8° step angle
// Arduino Stepper library with Motor Shield R3 pins
// Stepper(steps, pin1, pin2, pin3, pin4)
// pin1=DIR_A=11, pin2=DIR_B=4, pin3=PWM_A=9, pin4=PWM_B=3
// Note: For Motor Shield R3, we need to enable brakes off first
void setup() {
// Motor Shield R3 manual stepper control
// Channel A: PWM=9 (speed/enable), DIR=11
// Channel B: PWM=3 (speed/enable), DIR=4
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(7, OUTPUT); // Brake B
pinMode(8, OUTPUT); // Brake A
pinMode(9, OUTPUT);
pinMode(11, OUTPUT);
// Disable brakes
digitalWrite(7, LOW);
digitalWrite(8, LOW);
// Enable both channels at full power
analogWrite(9, 255);
analogWrite(3, 255);
}
// Full step sequence for bipolar stepper
const int step_table[4][2] = {
{HIGH, HIGH},
{LOW, HIGH},
{LOW, LOW},
{HIGH, LOW}
};
void step_motor(int direction, int steps, int step_delay_ms) {
for (int i = 0; i < steps; i++) {
static int current_step = 0;
current_step = (current_step + direction + 4) % 4;
digitalWrite(11, step_table[current_step][0]); // DIR A
digitalWrite(4, step_table[current_step][1]); // DIR B
delay(step_delay_ms);
}
}
void loop() {
step_motor(1, 200, 5); // 1 revolution CW, 5ms/step = 300 RPM
delay(1000);
step_motor(-1, 200, 5); // 1 revolution CCW
delay(1000);
}
Servo Motor Control
The Motor Shield R3 provides two dedicated servo headers at pins 9 and 10. Use the standard Arduino Servo library:
#include <Servo.h>
Servo servo1; // Connected to Motor Shield servo header 1 (Pin 9)
Servo servo2; // Connected to Motor Shield servo header 2 (Pin 10)
void setup() {
servo1.attach(9);
servo2.attach(10);
}
void loop() {
// Sweep servo 1 from 0° to 180°
for (int angle = 0; angle <= 180; angle++) {
servo1.write(angle);
delay(15);
}
for (int angle = 180; angle >= 0; angle--) {
servo1.write(angle);
delay(15);
}
}
Important: When using servos on the Motor Shield, note that pins 9 and 10 are shared with the DC motor PWM channels. You can use servos OR DC motors on those channels — not both simultaneously. Plan your pin usage accordingly.
Practical Projects
Project 1: Two-Wheel Robot Car
Connect two DC gear motors (one per channel), add an HC-SR04 ultrasonic sensor on free pins, and implement obstacle avoidance:
- Motor A → left wheel
- Motor B → right wheel
- HC-SR04 Trig → Pin 2, Echo → Pin 6
- Logic: if obstacle <20 cm → stop → reverse → turn right → proceed
Project 2: Motorized Camera Slider
Use Channel A to drive a stepper motor connected to a lead screw or timing belt. Channel B drives a second axis for pan. Control via Serial commands from a PC:
- Command “M100” → move 100 steps forward
- Command “S” → stop immediately
- Command “H” → home to limit switch
Project 3: Current-Sensing Motor Protection
Read the current sense output (A0 for Channel A) at 5 ms intervals. If current exceeds a threshold (motor stalled), trigger an emergency stop:
const float CURRENT_LIMIT = 1.5; // Amps
void checkCurrent() {
float current_A = analogRead(A0) * (5.0 / 1023.0) / 3.3;
if (current_A > CURRENT_LIMIT) {
motorA_brake(); // Emergency stop
Serial.println("STALL DETECTED - STOPPED");
while(1); // Halt until reset
}
}
Frequently Asked Questions
Can the Arduino Motor Shield R3 drive high-current motors?
The L298P is rated at 2 A continuous per channel. For motors drawing more than 2 A, use an external motor driver board (BTS7960, L298N module, or DRV8833) and control it with logic signals from the Arduino. The Motor Shield R3 is appropriate for small to medium hobby motors — typical 6V/12V gear motors, small bipolar steppers (NEMA 14/17 at low currents), and RC-style servo motors.
Why is my motor running slowly even at full PWM (255)?
The L298P has approximately 1.4 V forward voltage drop across the H-bridge. A 5 V motor supply gives the motor only ~3.6 V effective. Use a higher motor supply voltage: 7.5 V for 6 V motors, 13.5 V for 12 V motors. This is the most common reason for sluggish performance and is a property of all L298-family drivers.
Can I use the Motor Shield R3 with Arduino Mega?
Yes. The R3 connector standard (introduced with Arduino Uno R3) is compatible with the Arduino Mega 2560 R3. The shield stacks normally, and the same pins (D3, D4, D7, D8, D9, D11, D12, A0, A1) are used. The Mega’s extra pins are freely available for your sensors and peripherals.
Is there a library for the Arduino Motor Shield R3?
Arduino provides an official library in the Library Manager — search for “Arduino Motor Shield R3” or install the ArduinoMotorShieldR3 library. However, as shown above, direct register control with digitalWrite and analogWrite is straightforward and avoids library overhead. The direct approach gives you more control over braking behaviour and current sensing integration.
Can I control the Motor Shield R3 remotely via Bluetooth or WiFi?
Yes. Connect an HC-05 Bluetooth module to the Arduino’s hardware UART (pins 0/1) or a SoftwareSerial port (pins 5/6), and parse incoming commands to control the motors. For WiFi, the Arduino Nano 33 IoT has built-in WiFi/BLE — pair it with an external L298N motor driver board (since the Nano 33 IoT doesn’t have an R3 footprint compatible with the Motor Shield) for a wireless robot controller.
Conclusion
The Arduino Motor Shield R3 is the go-to motor driver for Arduino Uno-based robotics and automation projects. It’s easy to wire (just stack it), easy to code (direct PWM/direction writes or the official library), and packed with features including current sensing, brake control, and servo headers. Understand its 2 A per channel limitation and the L298P voltage drop, and you’ll build reliable motor control systems from your first prototype through to a finished product.
Ready to start driving motors? Find the Arduino Motor Shield R3, Arduino Uno R3, and all the accessories you need at Zbotic.in — your Arduino components store in India.
Add comment