TecnoMate logo
Motor Control with Arduino: DC, Servo, and Stepper Motors
Back to Guides
MotorsArduinoRobotics

Motor Control with Arduino: DC, Servo, and Stepper Motors

Feb 12, 2026
9 min read

Motor Control with Arduino: DC, Servo, and Stepper

Motors bring your projects to life—robots move, gates open, wheels spin. But you cannot connect a motor directly to an Arduino pin (it draws too much current and can damage the board). You need a motor driver circuit.

Types of Motors

| Motor Type | Motion | Control | Common Models | |-----------|--------|---------|---------------| | DC Motor | Continuous rotation | Speed (PWM) + direction | BO motor, N20 gear motor | | Servo Motor | Precise angle (0–180°) | Angle via PWM signal | SG90 (micro), MG996R (metal gear) | | Stepper Motor | Precise steps | Step + direction signals | 28BYJ-48, NEMA 17 |

DC Motor Control

Why You Need a Motor Driver

Arduino pins output maximum 40 mA at 5V. A small DC motor draws 200–500 mA at 6–12V. You need an H-bridge motor driver to handle the higher voltage and current.

L298N Motor Driver

The L298N is the most popular motor driver for student projects. It can drive two DC motors simultaneously.

| L298N Pin | Connect To | |-----------|----------| | IN1, IN2 | Arduino digital pins (direction) | | ENA | Arduino PWM pin (speed) | | Motor A terminals | DC motor wires | | 12V input | External power supply | | GND | Common ground with Arduino |

Speed Control with PWM

Use analogWrite() to set motor speed (0 = stop, 255 = full speed). Direction is set by toggling IN1 and IN2: one HIGH and the other LOW for forward, reverse the combination for backward.

Servo Motor Control

Servo motors rotate to a specific angle and hold position. They are used for robotic arms, pan-tilt camera mounts, and door locks.

Wiring

  • Red wire → 5V (external power for larger servos)
  • Brown/black wire → GND
  • Orange/yellow wire → Arduino PWM pin (e.g., D9)

Code

The Arduino Servo library makes control simple. Use servo.write(angle) where angle is 0–180 degrees. The servo moves to that angle and holds.

Important Notes

  • SG90 micro servos can be powered from Arduino 5V (they draw ~200 mA)
  • Larger servos (MG996R) need a separate 5V 2A power supply
  • Never force a servo beyond its range—it will strip the gears

Stepper Motor Control

Stepper motors rotate in precise steps (e.g., 1.8° per step = 200 steps per revolution for NEMA 17). They are used in 3D printers, CNC machines, and precision positioning.

28BYJ-48 with ULN2003 Driver

This is the cheapest stepper motor setup for beginners. The ULN2003 driver board connects directly to 4 Arduino pins.

NEMA 17 with A4988 Driver

For serious projects (3D printers, CNC). The A4988 supports microstepping (1/2, 1/4, 1/8, 1/16 steps) for smoother motion.

| Parameter | 28BYJ-48 | NEMA 17 | |-----------|----------|---------| | Step angle | 5.625° (64 steps/rev) | 1.8° (200 steps/rev) | | Voltage | 5V | 12V | | Torque | Low | High | | Driver | ULN2003 | A4988 / DRV8825 | | Cost | ₹100 | ₹500+ |

Common Mistakes

  1. Powering motors from Arduino 5V pin. The Arduino regulator can only supply ~500 mA total. Use an external power supply for motors.
  2. Missing common ground. The motor power supply GND must connect to Arduino GND.
  3. No flyback diode. DC motors generate voltage spikes when turning off. The L298N has built-in protection, but standalone H-bridges need flyback diodes.

Browse our Robotics Project Kits for complete motor control projects.


Ready to start building?

Explore our collection of DIY kits and components. All project components mentioned in this guide are available in our store.

Browse All Projects