For most small Arduino robots, a MOSFET-based motor driver such as the TB6612FNG or a suitable DRV883 module is a better starting point than the familiar L298N. The right choice depends on your motor’s type, voltage, and stall current—not just the biggest amp rating on a product listing.
Arduino motor drivers let your microcontroller control motors without asking its delicate output pins to supply motor power. We’ve seen a simple two-wheel robot behave perfectly on the bench, then reset every time a motor started; the culprit wasn’t the code, but a power supply that couldn’t handle the startup surge.
Below, we compare 12 popular driver options, explain safe wiring and Arduino code, and help you choose a driver that fits your project instead of merely looking impressive on a module listing.
Key Takeaways
- Match the driver to the motor. DC motors, steppers, servos, and brushless motors need different control hardware.
- Check stall current, voltage, and thermal limits before choosing a driver or power supply.
- The L298N is popular and well documented, but its voltage drop and heat make modern MOSFET drivers a better fit for many small battery-powered robots.
- Use a separate motor supply when needed and connect grounds as required by the driver’s control interface.
- Start tests slowly and safely. A stalled motor can draw far more current than it does while running freely.
- Use PWM for speed control, but remember that PWM sets motor power, not guaranteed speed. Encoders provide feedback when precise speed matters.
Table of Contents
- ⚡️ Quick Tips and Facts: Arduino Motor Drivers
- 🧭 Arduino Motor Driver Basics: What They Do and Why You Need One
- How an H-Bridge Controls Motor Direction
- Motor Driver vs. Motor Controller: What’s the Difference?
- Arduino Pins, Motor Voltage, and Current: The Essential Limits
- 📜 From L298N to Modern MOSFET Drivers: A Short History
- 🔍 How to Choose an Arduino Motor Driver
- Match the Driver to Your Motor Type
- Calculate Voltage, Stall Current, and Power Requirements
- Compare Channels, PWM, Braking, and Protection Features
- 🏆 12 Popular Arduino Motor Drivers Compared
- 1. L298N Dual H-Bridge Module
- 2. TB6612FNG Dual Motor Driver
- 3. DRV883 Dual Motor Driver
- 4. DRV8871 Single Motor Driver
- 5. BTS7960 High-Current H-Bridge
- 6. Adafruit Motor/Stepper/Servo Shield
- 7. Arduino Motor Shield Rev3
- 8. A498 Steper Motor Driver
- 9. DRV8825 Steper Motor Driver
- 10. TMC2209 Quiet Steper Driver
- 11. PCA9685 Servo Driver Board
- 12. ESCs for Brushless DC Motors
- 🛠️ Wiring an Arduino Motor Driver Safely
- Power Supply, Common Ground, and Motor Connections
- Connecting a DC Motor and Driver to an Arduino
- Wiring Steper Motors, Servos, and Brushless Motors
- Flyback Diodes, Capacitors, and Noise Suppression
- 💻 Arduino Motor Driver Code and Control
- Set Motor Direction with Digital Outputs
- Control DC Motor Speed with PWM
- Drive a Steper Motor with the Arduino Steper Library
- Use AccelStepper for Smother Motion
- Control a Servo with the Servo Library
- 📊 Arduino Motor Driver Specifications and Pinout Guide
- Reading a Driver Module Pinout
- Logic Voltage, Motor Voltage, and Current Ratings
- Thermal Limits, Heat Sinks, and Real-World Performance
- ⚖️ L298N vs. TB6612FNG vs. DRV883
- 🧪 Testing and Troubleshooting Motor Driver Problems
- Motor Won’t Spin or Only Runs in One Direction
- Driver Overheats, Resets, or Shuts Down
- Motor Jitters, Buzzes, or Runs at the Wrong Speed
- A Simple Multimeter and Bench-Test Checklist
- 🛡️ Safety, Battery Choice, and Reliable Build Practices
- 🤖 Arduino Motor Driver Project Ideas
- ✅ Quick Tips for Better Motor Control
- 🏁 Conclusion
- 🔗 Recommended Links
- ❓ FAQ
- Can an Arduino power a motor directly?
- Which motor driver is best for Arduino beginners?
- Can I use a 12V motor with a 5V Arduino?
- How do I reverse a DC motor with an Arduino?
- How do I control motor speed with PWM?
- Why does my motor driver get hot?
- Do Arduino motor drivers work with steper motors and servos?
- 📚 Reference Links
⚡️ Quick Tips and Facts: Arduino Motor Drivers
If you’re building an Arduino robot, start with our Arduino project guide, then choose a motor driver that matches the motor’s voltage, stall current, and type. Those three details matter more than a module’s impressive-looking amp rating.
| Quick fact | What it means for your build |
|---|---|
| Arduino GPIO pins are for signals, not motors | A motor needs more current than a microcontroller pin should supply. Use a motor driver between the Arduino and motor. Arduino’s electrical limits explain why. |
| DC motor speed is commonly controlled with PWM | PWM changes the motor’s effective power by switching it rapidly on and off. The Arduino PWM guide explains the basics. |
| A dual H-bridge can control two brushed DC motors | Each motor gets its own direction control and, on many drivers, PWM speed control. |
| Motor startup and stall current can exceed running current | Size the driver and supply for the motor’s stall current, not only its no-load current. |
| The L298N is popular, but inefficient by modern standards | Its bipolar-transistor output stage can lose substantial voltage as heat. A MOSFET-based driver is often a better fit for a small battery robot. STMicroelectronics’ L298 datasheet documents its electrical characteristics. |
| Motor power and Arduino power are separate design questions | A motor supply can cause voltage dips and electrical noise. A shared reference ground is usually needed for control signals, but the power rails should be planned deliberately. |
Our quick recommendation: For small brushed DC motors, consider a TB6612FNG or a suitable DRV883 module. Choose an L298N when you already have one, need a familiar teaching example, or have checked that its voltage loss and heat are acceptable.
One detail catches many first-time builders: a motor labeled “6 V” may draw several times its normal current when starting or stalled. We’ll show how to size for that before a driver turns into a tiny, expensive hand-warmer. ♨️
🧭 Arduino Motor Driver Basics: What They Do and Why You Need One
An Arduino motor driver is the power stage between a low-power controller and a motor. The Arduino decides what should happen; the driver switches the higher-current motor power that makes it happen.
Think of the Arduino as the conductor and the driver as the orchestra’s amplifier. The conductor can cue a dramatic crescendo, but shouldn’t try to power the loudspeakers directly.
How an H-Bridge Controls Motor Direction
A brushed DC motor changes direction when the direction of current through its terminals is reversed. An H-bridge does this electronically using four switching elements arranged around the motor.
| Switch pattern | Typical result |
|---|---|
| One diagonal pair on | Motor rotates in one direction |
| The opposite diagonal pair on | Motor rotates in the other direction |
| Both motor terminals driven to the same level | Motor stops or brakes, depending on the driver |
| Output switches disabled | Motor generally coasts, though exact behavior depends on the driver |
An H-bridge also allows the Arduino to control speed using PWM, provided the selected driver supports PWM in the intended configuration. Texas Instruments’ motor-driver resources explain common driver architectures and control approaches.
Watch the distinction: “Stop,” “coast,” and “brake” aren’t always interchangeable. A coast command usually lets the motor slow naturally. An active brake electrically resists rotation, which can stop a robot more quickly but may increase current and heat.
Motor Driver vs. Motor Controller: What’s the Difference?
People use these names loosely, but they can mean different things:
- Motor driver: A power-electronics board or IC that switches current to a motor.
- Motor controller: A broader system that may include a driver, feedback inputs, control logic, and safety features.
- Motor shield: A board that plugs into an Arduino and provides motor-driving circuitry and convenient connections.
A basic H-bridge module may accept direction and PWM signals without knowing the motor’s speed. A more advanced closed-loop controller can use an encoder to measure motion and adjust output automatically. For projects that combine motion sensing and control, browse our robotic sensors and automation guides.
Arduino Pins, Motor Voltage, and Current: The Essential Limits
An Arduino output pin is not a motor power source. A motor can demand high current at startup, when blocked, or when its shaft is under heavy load. That current can damage the controller, reset the board, or overheat wiring.
Before connecting anything, record:
- The motor’s rated voltage.
- Its stall current, if specified.
- The driver’s continuous and peak current ratings, with its cooling conditions.
- The supply’s voltage and current capability.
- Whether Arduino logic and driver inputs use compatible signal voltages.
Don’t rely on an advertised “maximum current” without checking the conditions behind it. A module’s peak rating may apply only briefly, with substantial cooling, or to the bare IC rather than a small breakout board. The L298 datasheet and TB6612FNG datasheet are better references than a listing headline.
📜 From L298N to Modern MOSFET Drivers: A Short History

The L298 became a classroom and hobby staple because it is easy to recognize, broadly available, and simple to demonstrate. Its dual H-bridge architecture makes it useful for teaching direction control, PWM, and the basics of motor wiring.
But motor-driver design has moved on. Modern MOSFET-based parts such as the TB6612FNG and DRV883 can waste less power in many low-voltage applications. That can mean less heat and more of a battery’s energy reaching the motor.
The change is not a simple “old bad, new good” story. The right choice depends on supply voltage, current, module quality, motor type, and what you already own. The L298N remains a workable learning board when its limitations are understood; it’s simply not our automatic pick for every compact robot.
🔍 How to Choose an Arduino Motor Driver
The easiest way to shop for a driver is to start with the motor rather than the Arduino board. Identify the electrical load first, then compare compatible drivers.
Match the Driver to Your Motor Type
| Motor type | Typical driver or interface | Key selection detail |
|---|---|---|
| Brushed DC motor | H-bridge module, such as TB6612FNG, DRV883, or L298N | Check voltage, stall current, and whether you need bidirectional control |
| Bipolar steper motor | A498, DRV8825, or TMC2209 steper driver | Match coil current, set the current limit, and configure microstepping |
| Hobby servo | Servo signal output, often using a control library or PWM expander | The servo usually needs a separate power supply sized for its current |
| Brushless DC motor (BLDC) | Electronic speed controller (ESC) | Match the ESC to the motor, battery, signal type, and application |
| Larger brushed motor | High-current H-bridge or dedicated motor controller | Check thermal performance, protection, wiring, and cooling—not just peak current |
A servo is not simply a DC motor with an H-bridge: it has its own control electronics and expects a position command. A steper driver is also different; it regulates winding current and advances the motor in controlled steps.
Calculate Voltage, Stall Current, and Power Requirements
Use this checklist before selecting a board:
- Find the motor’s rated voltage. Use the motor datasheet or manufacturer’s listing. Don’t assume a motor can safely take any supply voltage that the driver accepts.
- Look for stall current. This is the current the motor can draw when it cannot rotate. If the manufacturer doesn’t publish it, measure carefully with appropriate equipment or choose a conservative driver and current limit.
- Check the driver’s continuous rating. Compare it with the motor’s expected operating current, taking the module’s cooling and ambient temperature into account.
- Check transient and startup demands. A driver should tolerate brief startup loads without tripping, overheating, or resetting the Arduino.
- Choose a power supply that can deliver the load. A supply’s voltage can be correct while its current capacity is too low.
- Account for voltage drop and heat. The motor may receive less voltage than the supply provides, especially with older bipolar designs such as the L298.
A simple first-pass estimate is:
[P \approx V \times I
]
This is electrical input power, not a guarantee of motor output. It helps reveal whether a tiny board and thin jumper wires are being asked to do something heroic.
Compare Channels, PWM, Braking, and Protection Features
Before buying, ask:
- How many motors need independent control? A dual H-bridge can run two brushed DC motors, but two motors wired to one channel will share commands and current capacity.
- Does the board accept PWM where you need it? Some boards require removing an enable jumper or using particular pins.
- Does it provide current limiting or sensing? This is useful for steper tuning, load monitoring, and fault detection.
- What protections are built in? Look for thermal shutdown, overcurrent protection, undervoltage lockout, and reverse-polarity protection where appropriate.
- What logic voltage does it accept? Check compatibility with your Arduino’s I/O voltage; don’t assume every 3.3 V or 5 V board is interchangeable.
- Does the module have real thermal headroom? A bare IC’s datasheet rating may not match a small board’s practical capacity.
🏆 12 Popular Arduino Motor Drivers Compared
The table below is a starting point, not a substitute for checking the exact module revision and datasheet. Breakout boards sold under the same chip name can differ in connectors, cooling, regulators, and safe current.
| Driver or board | Best suited to | Main strengths | Main trade-offs |
|---|---|---|---|
| L298N module | Learning and legacy projects | Familiar, dual H-bridge, widely documented | Significant voltage loss and heat |
| TB6612FNG | Small two-motor robots | Efficient MOSFET design, compact | Verify module current and voltage limits |
| DRV883 | Small low-voltage motors | Compact dual H-bridge; common in battery projects | Board ratings vary; many versions have limited supply range |
| DRV8871 | One brushed DC motor | Single-motor control and current regulation on suitable boards | Not a dual-motor solution |
| BTS7960 | Higher-current brushed motors | Designed for heavier loads than tiny hobby modules | Module quality and cooling vary; bulky wiring |
| Adafruit Motor Shield V2 | Convenient multi-motor builds | Library support and multiple driver outputs | Uses an I²C interface and external motor supply |
| Arduino Motor Shield Rev3 | Arduino-compatible shield projects | Convenient pin mapping and current sensing | Uses L298; observe supply and thermal limitations |
| A498 | Bipolar steper projects | Step/direction interface and microstepping | Requires current-limit setup and adequate cooling |
| DRV8825 | Steper projects needing higher microstep options | Step/direction control and current regulation | Module and motor current limits must be checked |
| TMC2209 | Quiet, refined steper motion | Advanced configuration and quieter operation in suitable setups | More configuration; clone boards may differ |
| PCA9685 servo driver | Multiple hobby servo signals | Provides many servo control signals over I²C | It is not a motor power supply; servos need suitable external power |
| ESC for a BLDC motor | Brushless motors | Purpose-built brushless commutation | Must match motor and battery; setup differs from an H-bridge |
1. L298N Dual H-Bridge Module
The L298N is a recognizable choice for two brushed DC motors or, in suitable configurations, one bipolar steper. It’s easy to find tutorials for, which can be handy when your first goal is to make a robot move rather than decode a cryptic pinout.
Its big drawback is efficiency. The L298 uses bipolar transistors, so it can lose a meaningful portion of the supply voltage and dissipate that energy as heat. STMicroelectronics publishes the device’s electrical data in the L298 datasheet; inspect the voltage-drop figures before pairing it with a low-voltage motor.
Benefits
- Two H-bridge channels for two brushed DC motors.
- Common pin labels and abundant Arduino examples.
- Useful for demonstrations and simple legacy builds.
Drawbacks
- Voltage drop reduces the voltage available to the motor.
- Heat and current capacity depend on the module, airflow, and load.
- The onboard regulator and jumper behavior differ across module variants.
Our take: Use an L298N if you already own one or its familiar wiring helps you learn. For a new small battery-powered robot, compare a MOSFET driver before committing.
2. TB6612FNG Dual Motor Driver
The TB6612FNG is a dual brushed-DC motor driver based on MOSFET output stages. It’s a strong candidate for compact robots that need two independently controlled motors without the L298N’s characteristic voltage-drop penalty.
The key is to follow the exact board’s supply and current limits, not just the IC name. Toshiba’s TB6612FNG documentation describes the chip; the breakout board may have its own thermal and connector constraints.
Benefits
- Two motor channels with direction and PWM control.
- Efficient design for many low-voltage projects.
- Compact and widely supported by hobby hardware libraries.
Drawbacks
- Not intended to make an undersized motor or battery safe.
- Module ratings vary; check the seller’s documentation against the chip datasheet.
- High stall currents can still overheat the board.
Our take: A good first comparison point for small two-wheel robots when its voltage and current limits match the motors.
3. DRV883 Dual Motor Driver
The DRV883 is a compact dual H-bridge option used in small robotics and battery-powered designs. It can control two brushed DC motors or a suitable steper arrangement, depending on wiring and the module.
TI’s DRV883 datasheet is the authority for the IC’s electrical characteristics. A breakout’s continuous current capacity still depends on its PCB copper, layout, and cooling.
Benefits
- Compact, MOSFET-based design.
- Suitable for many small motors and battery projects.
- Often includes built-in protection features at the chip level.
Drawbacks
- Module versions differ, so confirm the supply range and current rating.
- Tiny boards have limited heat-dissipation area.
- Not a drop-in replacement for every L298N wiring diagram.
4. DRV8871 Single Motor Driver
The DRV8871 is a single brushed-DC motor driver, useful when you need one motor and want a modern driver IC rather than a two-channel board. Depending on the breakout, current regulation and control inputs can make it a tidy fit for a compact actuator or one-wheel mechanism.
Review TI’s DRV8871 datasheet and the specific board documentation before wiring it. “Single motor” doesn’t mean “any motor”; the load and thermal limits still rule.
5. BTS7960 High-Current H-Bridge
BTS7960-based modules are marketed for higher-current brushed-motor projects, but the word high-current should prompt more checking, not less. Module construction, heat sinking, wiring, and seller ratings can vary considerably.
Use the manufacturer’s documentation for the actual power IC and treat a module’s headline current as conditional. For larger motors, pay particular attention to wire gauge, fuse protection, connector ratings, and heat. A powerful driver can still be a poor match for a small breadboard.
6. Adafruit Motor/Stepper/Servo Shield
The Adafruit Motor Shield V2 offers a convenient expansion board with library support for motor projects. Check the current product documentation for the number and type of motors supported, supply requirements, and library setup: Adafruit Motor Shield V2.
Benefits
- Shield form factor keeps wiring organized.
- Software library simplifies initial control.
- Useful when a project needs several motor outputs.
Drawbacks
- A shield does not remove the need for a correctly sized external power source.
- Library abstractions can hide details you may want to learn.
- Verify compatibility with your specific Arduino and shield revision.
7. Arduino Motor Shield Rev3
Arduino’s Motor Shield Rev3 is built around the L298 and provides two channels, A and B. Arduino’s product documentation describes it as capable of 2 A per channel, with 4 A maximum total, and explains the board’s external power connections and jumpers. Those figures should be read alongside the L298’s heat and voltage-drop characteristics, not treated as a promise that every setup can sustain the maximum continuously.
The shield maps direction, PWM, braking, and current-sensing functions to Arduino pins. Its documentation also notes that the board can drive two brushed DC motors or one bipolar steper in an appropriate setup. See the official product page for pin assignments, schematics, and design files.
Benefits
- Convenient, documented Arduino shield layout.
- Current-sensing outputs and brake controls are available.
- Official schematics and design files support inspection and modification.
Drawbacks
- The L298 is less efficient than many MOSFET alternatives.
- Motor power must be planned separately from USB power.
- The board’s jumper and Vin arrangement needs careful attention.
8. A498 Steper Motor Driver
The A498 is a step-and-direction driver for bipolar steper motors. Rather than switching the motor like a basic DC H-bridge, it controls step progression and regulates winding current. That makes it useful for positioning tasks, provided you set its current limit correctly.
The Alegro A498 datasheet covers the chip’s operating details. Many breakout boards use a small potentiometer for current adjustment; follow the specific board instructions and use appropriate measurement procedures.
Benefits
- Familiar step/direction control.
- Microstepping support.
- Broad availability and many Arduino examples.
Drawbacks
- Incorrect current-limit adjustment can overheat the driver or motor.
- Cooling and board layout matter.
- Not for direct control of ordinary brushed DC motors.
9. DRV8825 Steper Motor Driver
The DRV8825 is another step-and-direction steper driver, often selected for projects needing microstepping and a higher supply-voltage range than some basic alternatives. The actual performance depends on the board, heat sinking, current setting, motor, and airflow.
Read TI’s DRV8825 datasheet and the breakout documentation before use. Never set the current based on another board’s potentiometer position; resistor values and layouts can differ.
10. TMC2209 Quiet Steper Driver
The TMC2209 is a more feature-rich steper-driver option, known for quiet operation in suitable configurations and advanced control options. It can be a good fit where smooth motion and lower audible motor noise matter, such as a desktop mechanism or a carefully tuned robot.
Trinamic’s product information and technical documents are available through Analog Devices’ TMC2209 page. Configuration options can vary by module, so check whether your board uses UART communication and what its pin configuration supports.
11. PCA9685 Servo Driver Board
The PCA9685 is a PWM controller commonly used to generate control signals for multiple servos. It is not a power amplifier for the motors: the servos still need an appropriately sized external supply. Adafruit’s PCA9685 guide explains wiring, I²C setup, and servo control.
Use it when a project needs many servo signals, not as a substitute for an H-bridge. For servo power and motion-sensing projects, our robotic sensors section offers related build ideas.
12. ESCs for Brushless DC Motors
A brushless DC motor typically needs an electronic speed controller (ESC) to perform its commutation. A standard brushed-motor H-bridge is not the right driver for a typical three-phase BLDC motor.
Choose an ESC that matches the motor, battery chemistry, current demand, and control signal. Follow the manufacturer’s setup instructions, secure the motor, and remove the propeller or other hazardous load during initial bench tests. For autonomous applications, pair motion control with suitable automation and sensor design rather than relying on open-loop throttle alone.
🛠️ Wiring an Arduino Motor Driver Safely
A tidy wiring diagram is useful, but the real win is a power layout that doesn’t make the Arduino reset every time a motor starts. Start with power and ground, then add control signals.
Power Supply, Common Ground, and Motor Connections
For a typical Arduino-plus-driver project:
- Connect the motor supply to the driver’s motor-power input.
- Connect the motor to the driver’s output terminals.
- Connect the Arduino signal pins to the driver’s logic inputs.
- Connect Arduino ground and driver ground together when the control interface requires a shared reference.
- Keep motor current out of thin signal wires and breadboard traces.
- Add a suitable fuse where the supply and application warrant it.
The Arduino and motor do not always need to share a positive supply rail. In many designs, they share ground while using separate power sources. Follow the particular module’s wiring diagram, especially if it has an onboard regulator or selectable power jumper.
Connecting a DC Motor and Driver to an Arduino
Here’s a safe, general workflow for a dual H-bridge module:
- Disconnect power. Don’t wire a live motor supply.
- Identify terminals and pins. Find motor outputs, motor-power input, ground, logic supply, direction inputs, and PWM or enable pins in the board documentation.
- Connect the motor supply. Use a voltage appropriate for both the motor and driver.
- Connect the motor. Attach its two leads to one H-bridge output pair.
- Connect grounds. Join the Arduino ground to driver ground when required by the interface.
- Wire logic signals. Connect direction and PWM pins to suitable Arduino digital outputs.
- Check jumpers. Some L298N modules have enable jumpers; a fitted jumper may bypass PWM speed control.
- Inspect polarity and loose strands. A stray wire can short a supply rail.
- Run a low-risk test. Use a restrained motor, low duty cycle, and a supply with appropriate protection.
- Monitor temperature and current. Stop immediately if anything heats rapidly or behaves unexpectedly.
The Arduino Project Hub example demonstrates an Uno-and-L298N wiring walkthrough, while its text gives a general battery and ground connection. Treat the visual diagram as part of that specific build, and verify your own module’s pinout before copying it. Arduino Project Hub L298N tutorial.
Wiring Steper Motors, Servos, and Brushless Motors
Stepper motor: Identify the coil pairs with the motor documentation or a meter. Connect them to the driver’s coil outputs, connect motor power, and set the current limit before sustained operation.
Servo: Connect signal, ground, and an appropriate servo power supply. Do not assume an Arduino’s 5 V pin can supply the combined current of several servos.
Brushless motor: Connect the motor phases to a compatible ESC, then connect the ESC’s battery input and control signal as documented. Initial tests should be performed with the motor mechanically safe and any propeller removed.
Each motor family has its own control model. For motion-control code and sensor feedback, see our coding languages resources and robotic simulations category.
Flyback Diodes, Capacitors, and Noise Suppression
Motors are inductive loads, so switching them can produce voltage spikes and electrical noise. Many driver ICs include recirculation paths and protection, but external suppression may still be appropriate depending on the motor, wiring, and module.
- Use the protection recommended by the driver manufacturer. Don’t add parts blindly; diode placement depends on the circuit.
- Keep motor leads short where practical.
- Place supply decoupling capacitors close to the driver, following the datasheet.
- Separate noisy motor wiring from sensitive sensor wiring.
- Add bulk capacitance if the design and driver documentation call for it.
- Test for Arduino resets when motors start, reverse, or brake.
If an ultrasonic sensor starts reporting phantom obstacles whenever a wheel motor runs, electrical noise or supply dips may be the culprit—not a sudden poltergeist in the workshop. 👻
💻 Arduino Motor Driver Code and Control
Code examples below are deliberately generic. Pin assignments and stop behavior differ among modules, so check your driver documentation before uploading. For background on Arduino programming and project structure, explore our coding languages category.
Set Motor Direction with Digital Outputs
For a typical H-bridge, two input pins select direction. The following example uses pins 7 and 8 for direction and pin 9 for PWM:
const int in1 = 7;
const int in2 = 8;
const int pwmPin = 9;
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(pwmPin, OUTPUT);
}
void loop() {
// Direction one
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(pwmPin, 120);
delay(200);
// Stop command: behavior depends on driver and wiring
analogWrite(pwmPin, 0);
delay(500);
// Reverse direction
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(pwmPin, 120);
delay(200);
}
``
**Important:** This assumes the driver exposes a PWM-capable enable input and that it is connected as expected. On an L298N module, the enable jumper may need to be removed to use PWM on the enable pin.
### [Control DC Motor Speed with PWM](#control-dc-motor-speed-with-pwm)
On many classic Arduino boards, `analogWrite()` accepts a value from **0 to 255**. That value controls PWM duty cycle; it is not a direct voltage command. Arduino’s [PWM documentation](https://docs.arduino.cc/learn/microcontrollers/analog-output/) covers board-specific behavior and pin support.
```cpp
const int pwmPin = 9;
void setup() {
pinMode(pwmPin, OUTPUT);
}
void loop() {
analogWrite(pwmPin, 80); // Lower duty cycle
delay(150);
analogWrite(pwmPin, 180); // Higher duty cycle
delay(150);
}
``
The average power delivered to the motor changes with PWM duty cycle, but a motor may not start at low settings. A HowToMechatronics L298N tutorial notes that low PWM can make a motor buzz without turning, and describes adjusting the minimum usable command for the motors in that build. That threshold is **motor- and load-specific**, not a universal number. [HowToMechatronics: Arduino DC motor control](https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/).
### [Drive a Steper Motor with the Arduino Steper Library](#drive-a-steper-motor-with-the-arduino-steper-library)
For a driver that accepts step and direction signals, the Arduino sends pulses to the driver, which advances the motor. Libraries can simplify motion commands, but they cannot compensate for incorrect coil wiring or an improperly set current limit.
The built-in [Arduino Steper library documentation](https://docs.arduino.cc/libraries/stepper/) is useful for basic steper setups. For smoother acceleration and more complex motion profiles, a dedicated library such as AccelStepper is often more practical.
### [Use AccelStepper for Smother Motion](#use-accelsteper-for-smother-motion)
AccelStepper supports common step/direction drivers and offers acceleration planning. Install it through the Arduino IDE Library Manager, then consult the [AccelStepper documentation](https://www.airspayce.com/mikem/arduino/AccelStepper/).
A basic pattern looks like this:
```cpp
# include <AccelStepper.h>
const int stepPin = 2;
const int dirPin = 3;
AccelStepper steper(AccelStepper::DRIVER, stepPin, dirPin);
void setup() {
steper.setMaxSpeed(800);
steper.setAcceleration(300);
steper.moveTo(160);
}
void loop() {
if (steper.distanceToGo() == 0) {
steper.moveTo(-steper.currentPosition());
}
steper.run();
}
``
The chosen speed and acceleration are example values, not recommended settings for every motor. Start conservatively, and verify that the driver current limit and motor supply are correct.
### [Control a Servo with the Servo Library](#control-a-servo-with-the-servo-library)
A hobby servo typically receives timed position commands rather than a DC-motor PWM duty command. The Arduino [Servo library reference](https://docs.arduino.cc/libraries/servo/) explains the standard interface.
```cpp
# include <Servo.h>
Servo arm;
void setup() {
arm.attach(9);
}
void loop() {
arm.write(30);
delay(800);
arm.write(150);
delay(800);
}
``
For more than a few servos, or for a project that needs stable external timing, a PCA9685 board may help. It still does not provide the servo motor’s power.
## [📊 Arduino Motor Driver Specifications and Pinout Guide](#arduino-motor-driver-specifications-and-pinout-guide)
Specifications are easiest to compare when you separate **chip-level data** from **module-level performance**. The chip manufacturer defines the IC’s operating conditions; the breakout-board maker determines how well the board can dissipate heat and handle its connectors.
### [Reading a Driver Module Pinout](#reading-a-driver-module-pinout)
Common labels include:
| Label | Typical meaning |
|---|---|
| `VM`, `VIN`, `VCC` | Motor supply input; exact meaning depends on board |
| `GND` | Ground reference |
| `VCC`, `VLOGIC`, `5V` | Logic supply or regulated output; check the documentation carefully |
| `OUT1`, `OUT2`, `A01`, `A02` | Motor output pair for one channel |
| `IN1`, `IN2` | Direction-control inputs |
| `EN`, `PWMA`, `PWMB` | Enable or PWM input |
| `STEP`, `DIR` | Steper-driver pulse and direction inputs |
| `SLEEP`, `STBY` | Standby or sleep control |
| `SNS`, `ISEN` | Current-sense connection on some drivers |
A pin labeled `5V` may be an input, an output, or part of a jumper-selectable regulator circuit. Never infer its role from the label alone.
### [Logic Voltage, Motor Voltage, and Current Ratings](#logic-voltage-motor-voltage-and-current-ratings)
| Rating | What to verify |
|---|---|
| Motor-supply range | The lowest and highest voltage supported by the IC and module |
| Logic-input voltage | Whether Arduino HIGH levels are reliably recognized |
| Continuous current | Current the board can sustain under stated thermal conditions |
| Peak current | How long the driver can tolerate brief higher demand |
| Current limit | Whether it can be adjusted or is fixed |
| Thermal shutdown | Whether the IC protects itself when too hot |
| Reverse-polarity protection | Whether the module can survive a reversed supply connection |
The number that matters most for a long-running project is not necessarily the largest printed on the listing. Find the condition under which it applies and confirm that your board can meet it.
### [Thermal Limits, Heat Sinks, and Real-World Performance](#thermal-limits-heat-sinks-and-real-world-performance)
A driver can be electrically within its voltage range and still overheat because of current, switching losses, poor airflow, or an undersized PCB. Heat sinks help only when they have a useful thermal path to the part that is heating.
As a rule of thumb:
- If a driver becomes too hot touch quickly, **power down and investigate**.
- Reduce the load or PWM duty cycle while diagnosing.
- Check for a stalled motor, wrong coil pairing, or a shorted output.
- Improve airflow only after confirming the current is within the driver’s documented limits.
- Don’t use a heat sink to justify exceeding the datasheet.
## [⚖️ L298N vs. TB6612FNG vs. DRV883](#l298n-vs-tb6612fng-vs-drv883)
| Consideration | L298N | TB6612FNG | DRV883 |
|---|---|---|---|
| Driver architecture | Bipolar-transistor H-bridge | MOSFET H-bridge | MOSFET H-bridge |
| Typical project fit | Learning, older designs, higher-voltage examples | Compact two-motor robots | Small low-voltage motor projects |
| Voltage loss | Can be substantial | Generally lower than L298 in suitable conditions | Generally efficient at supported loads |
| Board size | Often relatively large | Usually compact | Usually compact |
| Documentation | Extensive hobby tutorials | Manufacturer datasheet and module guides | Manufacturer datasheet and module guides |
| Main caution | Heat and motor voltage drop | Verify the breakout’s thermal/current limits | Check module current, supply, and thermal limits |
**Which one should you choose?**
- Pick **L298N** when you have one already, want a familiar teaching setup, or need to follow an L298-specific tutorial.
- Pick **TB6612FNG** for a compact two-motor robot when the motor requirements fit the module.
- Pick **DRV883** for a suitable small-motor project when its exact voltage and current limits match.
The official Arduino Motor Shield Rev3 specification says the shield “can supply 2 amperes per channel, for a total of 4 amperes maximum.” That’s useful context for that board, but it doesn’t erase the L298’s thermal considerations. The HowToMechatronics tutorial separately describes an approximately 2 V drop in its L298N setup. The figures refer to different aspects of use—rated channel capability versus voltage lost across the driver—so they aren’t contradictory. Trust the **datasheet and board-specific documentation**, and treat a headline maximum as conditional. [Arduino Motor Shield Rev3](https://store.arduino.cc/products/arduino-motor-shield-rev3) · [HowToMechatronics L298N tutorial](https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/).
## [🧪 Testing and Troubleshooting Motor Driver Problems](#testing-and-troubleshooting-motor-driver-problems)
Start with the simplest possible test: one motor, one channel, a known-good power supply, and short code. Add sensors and robot logic only after basic motor control works.
### [Motor Won’t Spin or Only Runs in One Direction](#motor-wont-spin-or-only-runs-in-one-direction)
Check these in order:
1. Confirm the motor supply is connected to the correct terminals.
2. Measure the supply voltage at the driver while the motor command is active.
3. Confirm Arduino and driver grounds share a reference where required.
4. Check the direction-input pin assignments in both wiring and code.
5. Inspect enable pins and jumpers; the channel may be disabled or held at full speed.
6. Test the motor directly with a suitable, current-limited supply if safe to do so.
7. Swap the motor leads to see whether the issue follows the motor or the channel.
If one direction works and the other doesn’t, suspect a control pin, wiring connection, or damaged H-bridge leg before rewriting the whole program.
### [Driver Overheats, Resets, or Shuts Down](#driver-overheats-resets-or-shuts-down)
Possible causes include:
- Motor stall current exceeds the driver’s practical rating.
- The supply voltage is outside the driver’s limits.
- The motor is mechanically jamed or overloaded.
- A steper current limit is too high.
- The Arduino and motor share a weak supply that sags on startup.
- Wiring is undersized or connections are loose.
- The board lacks sufficient heat dissipation for the actual load.
**Stop and disconnect power** if you smell overheated insulation, see smoke, or notice a component heating rapidly. Don’t keep cycling a driver that is repeatedly entering thermal shutdown.
### [Motor Jitters, Buzzes, or Runs at the Wrong Speed](#motor-jitters-buzzes-or-runs-at-the-wrong-speed)
Jitter and buzzing may point to:
- PWM duty cycle below the motor’s starting threshold.
- A low or unstable motor supply.
- Incorrect steper coil pairing.
- An unsuitable PWM frequency for the motor and driver.
- Electrical noise affecting sensor or control wiring.
- Mechanical binding or an overloaded motor.
- A floating enable, standby, or sleep pin.
A HowToMechatronics example describes a motor that buzzed at low PWM settings and needed a motor-specific starting threshold. That’s a useful troubleshooting clue, not a universal “set PWM to this number” prescription. [Tutorial and example](https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/).
### [A Simple Multimeter and Bench-Test Checklist](#a-simple-multimeter-and-bench-test-checklist)
- **Power off:** Inspect polarity, shorts, and terminal tightness.
- **Power on, motor disconnected:** Measure the driver supply.
- **Control test:** Confirm direction inputs and PWM output with a meter or logic analyzer.
- **Motor test:** Connect one motor and begin with a low command.
- **Load test:** Increase load gradually while monitoring voltage and driver temperature.
- **Reset test:** Check whether starting or braking the motor resets the Arduino.
- **Document results:** Record supply voltage, motor model, driver board, and observed current.
A short video demonstration can help visualize the sequence from concept to hardware: the cited [motor-control walkthrough](https://www.youtube.com/watch?v=ygrsIqWOh3Y&t=0s) shows a range of driver modules, illustrates PWM duty-cycle changes, and later depicts an Uno connected to an L298N. These visuals are useful for orientation; the datasheet remains the authority for safe electrical limits.
## [🛡️ Safety, Battery Choice, and Reliable Build Practices](#safety-battery-choice-and-reliable-build-practices)
Motors turn electrical mistakes into heat, movement, and occasionally airborne parts. Keep the first test boring—in robotics, boring is a compliment.
- **Secure the robot or motor** before testing.
- **Remove wheels, blades, or propellers** if they could cause injury.
- **Use a power source with suitable voltage and current capacity.**
- **Protect batteries against short circuits** and use a charger intended for their chemistry.
- **Add an appropriately rated fuse** when the supply and application call for it.
- **Avoid loose jumper wires for high-current paths.**
- **Keep a hand near the power switch** during initial testing.
- **Do not connect an unknown battery pack by guesswork.**
For Li-ion battery projects, follow recognized battery-handling guidance from the battery manufacturer and use a correctly matched charger and protection system. The [U.S. Consumer Product Safety Commission battery safety resources](https://www.cpsc.gov/Safety-Education/Safety-Education-Centers/Batteries) offer consumer safety information.
## [🤖 Arduino Motor Driver Project Ideas](#arduino-motor-driver-project-ideas)
| Project | Suggested control setup | What you’ll learn |
|---|---|---|
| Two-wheel robot car | Dual H-bridge plus two brushed DC motors | Differential steering, PWM, and power distribution |
| Potentiometer speed test rig | One DC motor, driver, and potentiometer | Mapping analog readings to PWM |
| Joystick rover | Dual H-bridge and two-axis joystick | Dead zones, steering mix, and speed limits |
| Steper-powered camera slider | Steper driver and bipolar steper | Positioning, acceleration, and repeatable motion |
| Servo pan-and-tilt mount | Two servos or a PWM expander | Position commands and coordinated movement |
| Sensor-driven obstacle avoider | Motor driver plus ultrasonic or distance sensor | Closed-loop reactions and sensor integration |
| Small conveyor demonstrator | DC motor driver and switch or optical sensor | Automation, timing, and jam detection |
A classic starting point is an Arduino Uno and L298N project that demonstrates motor direction and speed control. The [Arduino Project Hub tutorial](https://projecthub.arduino.cc/lakshyajhalani56/l298n-motor-driver-arduino-motors-motor-driver-l298n-7e1b3b) includes wiring visuals and a video, while [HowToMechatronics’ tutorial](https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/) adds a PWM and joystick-robot discussion. Compare both with the actual module documentation before building.
## [✅ Quick Tips for Better Motor Control](#quick-tips-for-better-motor-control)
- **Read the motor and driver datasheets first.** Product titles are not engineering specifications.
- **Size for stall current.** Normal running current can be misleading.
- **Choose a driver for the motor type.** A DC H-bridge, steper driver, servo interface, and ESC are not interchangeable.
- **Use a separate motor supply when needed.** Don’t ask a USB-powered Arduino to feed a hungry motor.
- **Share ground when the control interface requires it.** Keep the power arrangement consistent with the driver’s documentation.
- **Start with low speed and no load.** Add load gradually.
- **Test braking separately from coasting.** The stop behavior affects current and motion.
- **Keep motor and sensor wiring apart.** This can reduce noise-related surprises.
- **Prefer a modern MOSFET driver for many small battery builds.** Keep the L298N for learning or for projects where its trade-offs are acceptable.
- **Use feedback for precision.** Open-loop PWM controls power, not guaranteed speed; encoders help measure what the motor actually does.