Why Can't Arduino Directly Control a Motor?
A motor is hungry for power — way more than a tiny Arduino pin can safely give. Here's why you need a motor driver in between, and how to wire one up yourself.
The Big Question ⚡
You wire your motor straight to an Arduino pin, run your code, and... nothing happens. Or worse — something smells hot. What went wrong?
The answer is simple: a motor asks for far more electricity than an Arduino pin is allowed to give. An Arduino pin can safely supply only a tiny trickle of current. A motor, especially when it first starts spinning, gulps down a much bigger current — sometimes ten times more or beyond.
Imagine trying to push a heavy shopping cart using only one finger. You just don't have enough strength — and if you push too hard trying to force it, you might hurt your finger. A motor driver is like a strong friend standing next to you: you give a light tap on their shoulder to say "go," and they do the actual heavy pushing.
Meet the Three Team Members
Just like with a relay, this setup has three characters — but this time the middle one can do something extra: control speed and direction.
Arduino
The brain. It sends small control signals — "go forward," "go backward," "how fast" — nothing more.
Motor Driver
The muscle-translator. It takes the Arduino's tiny signal and uses it to switch a much bigger current from a separate power supply.
Motor
The mover. It gets the strong current it actually needs, straight from the driver, and spins.
Two Reasons a Direct Wire Goes Wrong
It's not just about strength — there's a second, sneakier problem too.
Motor drivers include a set of diodes (sometimes called flyback or freewheeling diodes) built right in, whose only job is to catch that back-EMF spike and let it fade away safely, instead of zapping your Arduino.
What You'll Need
- 🧠 Arduino Uno (or similar)
- 🔋 L298N motor driver module
- ⚙️ A small DC hobby motor
- 🔌 A separate motor power supply (6-12V battery pack)
- 🔗 Jumper wires
- 💻 USB cable + Arduino IDE
Always check your motor's rated voltage before choosing a battery pack. Too much voltage can burn out the motor or the driver. Never power a motor straight from the Arduino's 5V pin — it can't supply enough current.
Step-by-Step: Build It!
-
Power down everything first
Disconnect the Arduino's USB cable and the motor's battery pack before wiring anything.
-
Wire the driver's logic side
Connect the L298N's IN1 and IN2 pins to Arduino digital pins 8 and 9, and its ENA pin to Arduino PWM pin 10. Connect the driver's GND to Arduino GND.
-
Wire the motor's power side separately
Connect your battery pack's positive and negative wires to the driver's 12V and GND power screw terminals. Connect the motor's two leads to the driver's OUT1 and OUT2 terminals.
-
Keep the two power sources separate
The Arduino's own 5V should never feed the motor directly — only the battery pack powers the motor, through the driver.
-
Upload the code
Plug the Arduino into your computer and upload the sketch from the next section using the Arduino IDE.
-
Power up the motor supply
Now connect the separate battery pack for the motor side.
-
Watch it spin!
Your motor should spin forward, pause, then spin backward — all controlled safely through the driver.
The Full Circuit Diagram
Here's how the low-power control side and the high-power motor side connect through the driver.
The Code: Teaching Arduino to Drive the Motor
This sketch spins the motor forward for two seconds, stops, spins backward for two seconds, then stops again.
// Arduino Motor Driver Demo
// Spins a separate motor forward and backward through an L298N driver
const int IN1 = 8; // direction pin 1
const int IN2 = 9; // direction pin 2
const int ENA = 10; // speed pin (PWM)
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
}
void loop() {
// Spin forward
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(ENA, 200); // speed: 0-255
delay(2000);
// Stop briefly
analogWrite(ENA, 0);
delay(500);
// Spin backward
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
analogWrite(ENA, 200);
delay(2000);
// Stop briefly
analogWrite(ENA, 0);
delay(500);
}- IN1 / IN2 tell the driver which way to route current through the motor, controlling direction.
- ENA uses PWM (analogWrite) to control speed, from 0 (stopped) to 255 (full speed) — the Arduino still only sends a control signal, never the motor's actual power.
- Swapping which of IN1/IN2 is HIGH reverses the motor's spin direction.
- The driver's onboard diodes quietly absorb any back-EMF spikes when the motor stops or reverses.
Safety First! ⚠️
Always disconnect power before wiring anything. Double-check your motor's voltage rating matches your battery pack. Keep the Arduino's 5V logic wiring separate from the motor's battery wiring, and never wire a motor straight to an Arduino pin — that's exactly the mistake this whole project is teaching you to avoid!
Frequently Asked Questions
Why can't Arduino pins power a motor directly?
An Arduino pin can only safely supply a small amount of current, while even a small motor can pull far more, especially when starting — enough to damage the pin.
What is back-EMF and why is it dangerous?
It's a voltage spike a motor generates when it slows down or loses power suddenly, because a spinning motor briefly acts like a generator. That spike can flow back and harm the Arduino.
What does a motor driver actually do?
It takes a tiny control signal and uses it to switch a separate, stronger power supply on and off, so the motor gets the power it needs safely.
What is an H-bridge?
It's a circuit of four switches arranged like the letter H, which lets a driver reverse current through a motor so it can spin forward, backward, or stop.
Can I use a transistor instead of a motor driver module?
For a simple one-direction motor, a single transistor with a flyback diode can work. For controlling direction or bigger motors, a driver module like the L298N is much easier and safer.
You Did It!
Now you know why motors need a translator between them and your Arduino: a motor driver, standing in as the strong friend who handles the heavy lifting while your Arduino just points the way.

Comments
Post a Comment