All lessons
⚙️Components 6 min read

Motors

Making things spin — and why motors need their own power.

In 10 seconds

  • Motors need far more current than a pin can give.
  • Use a driver board plus a separate battery.
  • Always join the grounds together.

Motors are where projects stop sitting on the desk and start moving across the floor. A DC motor is a wonderfully simple device: send electricity through it and a shaft spins. Reverse the electricity and it spins the other way. Give it less voltage and it spins slower. That is almost everything you need to know about the motor itself — the interesting part is how you connect it to an Arduino.

Never wire a motor straight to a pin

An Arduino pin can supply about 20 milliamps safely, and 40 at absolute maximum. A small hobby motor wants 200 to 800 milliamps, sometimes more when it starts up or when a wheel is blocked. Connecting one directly will, at best, make the board reset and at worst permanently damage the pin. This is not being cautious — it genuinely breaks boards, and it is the most common way beginners kill their first Arduino.

Use a driver

A motor driver is a middleman. Your Arduino sends it small, polite control signals, and the driver switches a much bigger battery current through to the motors. The popular L298N board takes four control pins for two motors, plus two speed pins, and screw terminals for the battery and the motors themselves.

Two rules make driver wiring work every time:

  • The motor battery connects to the driver, not to the Arduino.
  • The battery's ground and the Arduino's GND must be joined together. Without a shared ground the two halves cannot agree on what zero volts means, and the robot behaves like it is haunted.

Direction and speed

Each motor uses two control pins. Set the first HIGH and the second LOW and it spins forward; swap them and it spins backwards; set both the same and it stops. The enable pin takes analogWrite() from 0 to 255 to control speed with PWM. If a wheel spins the wrong way when you build a car, you do not need to change any code — just swap that motor's two wires.

The three types you will meet

  • DC gear motor — cheap, fast, great for wheels. Has no idea where it is or how far it has travelled.
  • Servo — moves to a precise angle and holds it. Perfect for arms, doors and steering.
  • Stepper — rotates in exact, countable steps. Used in 3D printers and anywhere you need precision over many turns.

Why motors misbehave

Motors are electrically noisy. As they spin they generate spikes that travel back down the wires and confuse the Arduino, causing random resets. Separate power supplies fix most of this. Soldering a small 0.1µF capacitor across the motor's terminals fixes most of the rest. If your project works perfectly until the motors start, suspect power before you suspect your code.

Quick quiz: Motors

3 questions to check it stuck.

Take the quiz

Next lesson

🦿 Servos

Keep learning

Ready to try it for real?

Reading is good. Wiring is better. Pick a project and put this to work.

Explore projects