04
intermediate+250 XP
L298N Motor Driver
Control a DC motor in both directions using the L298N H-bridge motor driver.
🎯 Objective
Use the L298N IC to spin a motor forward and backward.
📖 Background Theory
The L298N is a dual H-bridge driver IC. It can:
- Control 2 DC motors simultaneously
- Reverse motor direction by swapping which inputs are HIGH/LOW
- Control speed via PWM on the ENA/ENB pins
**Direction control:**
Forward: IN1=HIGH, IN2=LOW
Reverse: IN1=LOW, IN2=HIGH
Brake: IN1=HIGH, IN2=HIGH
Stop: IN1=LOW, IN2=LOW
**ENA pin:**
Set HIGH to enable motor A. Use PWM for speed control: analogWrite(ENA, 0-255)
🔧 Components You'll Use
Arduino UnoL298nDc MotorBatteryGround
📋 Steps (7)
- 1Place Arduino Uno, L298N, DC Motor, Battery, and Ground
- 2Wire L298N VCC to Battery +
- 3Wire L298N GND to Ground
- 4Wire L298N OUT1 and OUT2 to Motor pins
- 5Wire Arduino D4 → L298N IN1, D5 → IN2
- 6Wire Arduino D9 (PWM) → L298N ENA
- 7Paste the starter code, run simulation