Hooking a motor straight to an Arduino pin is the quickest way to reset the board or fry the pin. Each type of motor needs its own go-between: an H-bridge, a pulse signal or a driver. In this guide you’ll see the differences between DC, servo and stepper motors, which driver to use with each one and how to power everything without trouble.
In short
- An Arduino Uno pin is rated for about 20 mA at most: no motor connects directly.
- DC with an H-bridge (TB6612FNG beats the L298N), servo with a 50 Hz signal, stepper with an A4988 or DRV8825 type driver.
- Motors run from a separate power supply with a common GND shared with the Arduino.
The three types of motor
| DC motor | Servo | Stepper | |
|---|---|---|---|
| What you control | Speed and direction | Angle | Exact position, step by step |
| Wires | 2 | 3 (power, GND, signal) | 4 on the usual bipolar ones |
| Go-between | H-bridge or MOSFET | None for the signal; separate supply, yes | Dedicated driver |
| Position accuracy | None without a sensor | Good within its range | Very good if it doesn’t skip steps |
| Idle consumption | Zero when stopped | Holds torque, draws current | Holds current, gets hot |
| Typical uses | Robot wheels, fans, pumps | Arms, rudders, flaps | 3D printers, CNC, platforms |
Why they don’t connect directly to a pin
There are three reasons, and any one of them is enough:
- Current: a pin on the Uno’s ATmega328P has an absolute maximum of 40 mA, and it’s best not to go over 20 mA. A small DC motor draws hundreds of mA when it starts.
- Inductive voltage: when the current is cut off, the motor coil generates a voltage spike that can damage the pin. It’s the same problem as with relays.
- Noise: brushes and start-ups cause supply dips that reset the microcontroller.
If you only need one direction of rotation, a MOSFET with a diode is enough, as explained in the transistor as a switch. To change direction, you need an H-bridge.
DC motors: the H-bridge
An H-bridge is four switches arranged so that current can flow through the motor in one direction or the other. The Arduino only tells it the direction (two pins) and the speed (one PWM pin).

L298N vs TB6612FNG
| L298N | TB6612FNG | |
|---|---|---|
| Technology | Bipolar transistors | MOSFET |
| Voltage drop | High: you lose around 2 V or more | Low |
| Motor voltage | Up to 46 V | Up to 15 V |
| Current per channel | Up to 2 A with a heat sink | 1.2 A continuous (3.2 A peaks) |
| Heat | A lot; it has a heat sink | Little |
| Module size | Large | Very small |
Why the drop matters: with an L298N powered at 6 V, the motor may only get about 4 V. You lose speed and torque, and the chip turns the rest into heat. For small 3 to 12 V motors, the TB6612FNG is almost always the better choice. The L298N makes sense with voltages or currents the TB6612FNG can’t handle.
TB6612FNG example
Wiring for one channel (A):
Arduino D5 (PWM) -> PWMA
Arduino D7 -> AIN1
Arduino D8 -> AIN2
Arduino 5V -> VCC (logic)
Motor supply + -> VM
Common GND -> GND
5V or pin -> STBY (high to enable)
Motor -> A01 and A02
const int PWMA = 5, AIN1 = 7, AIN2 = 8;
void setup() {
pinMode(PWMA, OUTPUT);
pinMode(AIN1, OUTPUT);
pinMode(AIN2, OUTPUT);
}
void motor(int velocidad) { // -255 to 255
digitalWrite(AIN1, velocidad > 0);
digitalWrite(AIN2, velocidad < 0);
analogWrite(PWMA, abs(velocidad));
}
void loop() {
motor(200); delay(2000);
motor(0); delay(500);
motor(-200); delay(2000);
motor(0); delay(500);
}
Reversing direction at full speed causes heavy current spikes. Stop at 0 for a moment before reversing, as in the example.
Servos: 50 Hz pulses
A hobby servo contains a DC motor, a gearbox, a potentiometer and its own control circuit. You only send it a 50 Hz signal (one pulse every 20 ms) whose width sets the position:
| Pulse width | Usual position |
|---|---|
| about 1 ms | One end |
| about 1.5 ms | Center |
| about 2 ms | Other end |

The exact ranges vary from model to model. The Servo library takes care of generating the signal; you’ll find the code and the PWM details in the guide to PWM on Arduino and ESP32.
What really matters here is power. The signal wire goes to the pin, but the servo’s positive lead shouldn’t go to the Arduino’s 5V unless it’s an unloaded micro servo. When moving or under load, a servo can draw peaks of several hundred mA, and with several of them, more than an amp. The symptoms of powering them from the board are classic: jitter, erratic movements and resets.
If you drive lots of servos, a PCA9685 module generates up to 16 signals over I2C and frees up the Arduino’s timers.
Continuous rotation servo
It looks like a servo, but it has no position: a 1.5 ms pulse stops it and the extremes set speed and direction. It’s a DC motor with a gearbox and built-in control.
Stepper motors
A stepper motor moves in fixed steps; the typical NEMA 17 does 200 steps per revolution (1.8° per step). Bipolar steppers have two coils and four wires. They don’t move by “switching on and off”: the coils have to be energized in sequence, and that’s what the driver does.
A4988 vs DRV8825
| A4988 | DRV8825 | |
|---|---|---|
| Motor voltage | Up to 35 V | Up to 45 V |
| Current without heat sink | About 1 A per phase | About 1.5 A per phase |
| Microstepping | Up to 1/16 | Up to 1/32 |
| Usual current limit formula | I = Vref / (8 × Rs) | I = Vref × 2 (modules with 0.1 Ω Rs) |
Both use just two pins: STEP (each pulse is one step or microstep) and DIR (direction).
const int STEP = 3, DIR = 4;
void setup() {
pinMode(STEP, OUTPUT);
pinMode(DIR, OUTPUT);
}
void loop() {
digitalWrite(DIR, HIGH);
for (int i = 0; i < 200; i++) { // one revolution in full-step mode
digitalWrite(STEP, HIGH);
delayMicroseconds(800);
digitalWrite(STEP, LOW);
delayMicroseconds(800);
}
delay(1000);
}
For smooth acceleration, the AccelStepper library keeps the motor from skipping steps when it starts.
Setting the current limit is mandatory
These drivers regulate the coil current, and the maximum is set with the module’s potentiometer by measuring Vref with a multimeter. Steps:
- Look up the motor’s rated current in its datasheet (for example, 1.5 A per phase).
- Identify the module’s sense resistors (Rs): they’re usually marked R050, R068 or R100 (0.05, 0.068 or 0.1 Ω).
- Calculate Vref with your driver’s formula and start somewhat below the maximum.
- With the driver powered, measure between the potentiometer and GND and adjust.
On an A4988 with 0.1 Ω Rs, for 1 A:
Vref = I × 8 × Rs = 1 × 8 × 0.1 = 0.8 V
The multimeter procedure is covered in detail in calibrating the drivers (Vref).
Separate power and common GND
The rule applies to all three types:
- Motors are powered from their own supply, sized for the total current.
- The Arduino can run from USB or another supply.
- The GNDs are tied together. Without a common ground, the Arduino’s signal has no reference and the driver doesn’t understand it or behaves erratically.
- Put an electrolytic capacitor (100 µF or more) between VM/VMOT and GND, close to the driver. It absorbs the spikes when you plug in.
Motor supply + -> driver VM / VMOT
Motor supply - -> driver GND -> Arduino GND
Arduino pins -> driver control inputs
Common mistakes
- Powering motors from the Arduino’s 5V. Resets and hot regulators.
- Forgetting the common GND. The motor doesn’t respond or moves in jerks.
- Disconnecting a stepper while the driver is powered. The voltage spike can destroy the driver instantly.
- Not setting Vref. Too low and it skips steps; too high and the motor and driver overheat.
- Using an L298N at 5 or 6 V. The internal drop leaves the motor starved of voltage.
- Reversing direction abruptly at full speed. Stop for an instant first.



