1 Why you can't drive a motor from a pin
An Arduino Uno pin can source or sink only about 40 mA — enough for an LED, but a small DC motor draws hundreds of milliamps at stall. Connecting a motor directly would instantly damage the microcontroller.
There is a second hazard: back-EMF. When the magnetic field inside a spinning motor collapses, it generates a voltage spike in the opposite direction. Without protection that spike can reach tens of volts and destroy the driver or the Arduino.
The solution is a dedicated motor driver IC. The L298N is the classic choice for teaching: it contains two full H-bridges rated for up to 2 A per channel and 46 V, with built-in protection diodes that absorb back-EMF spikes. The Arduino only controls logic pins on the L298N; the heavy current comes from a separate motor supply.
- IN1 / IN2 — logic inputs that set the motor direction.
- ENA — enable pin; a PWM signal here controls speed (duty cycle = fraction of maximum speed).
- OUT1 / OUT2 — output terminals that actually connect to the motor leads.
- 12 V — motor supply input (can be 6–46 V for the L298N; we use a 9 V battery in the simulator).
- GND — common ground: must be shared between the L298N, the motor supply, and the Arduino. Without a common GND the logic voltage reference is undefined and nothing works.