L298N Motor Driver with Arduino: DC Motor Control Guide

Realistic wiring diagram of an L298N motor driver module connected to an Arduino Uno and two DC motors for controlling direction and speed.

The L298N is a dual H-bridge motor driver, and it is one of the most common ways to control DC motors with an Arduino. Here I go through the pinout, how to wire it up, how PWM speed control actually works, and how to set motor direction in code. There is also a troubleshooting section for the issues that tend to come up.