Lab
The H-bridge: four switches, one motor
A DC motor turns one way when current goes through it one way, and the other way when it goes through the other way. The L298N motor driver swaps that direction with four switches arranged like the letter H, the motor across the middle. Each side of the car has one of these bridges.
Start with IN1 HIGH and IN2 LOW and follow the current. Then swap them and watch the same motor turn the other way. Then set both HIGH, and then switch ENA off: two different ways to stop.
Last, tap the car’s letters. Each one is just a pattern on the four IN pins.
| letter | IN1 | IN2 | IN3 | IN4 | side A | side B |
|---|---|---|---|---|---|---|
| F | L | H | H | L | forward | forward |
| B | H | L | L | H | backward | backward |
| L | H | L | H | L | backward | forward |
| R | L | H | L | H | forward | backward |
| S | H | H | H | H | brake | brake |
Say your answer out loud, then open this
What this shows
An H-bridge is four switches in a square with the motor across the middle, drawn like the letter H. Closing the top-left and bottom-right switches sends current through the motor one way; closing the other diagonal sends it the other way. The motor never changes, only the path through it.
On the L298N each IN pin decides one end of the motor: IN1 HIGH ties OUT1 to the battery's plus, IN1 LOW ties it to ground, and IN2 does the same for OUT2. HIGH and LOW turn the motor one way, LOW and HIGH the other way. ENA switches the whole bridge on or off, so each motor channel needs three control pins, not four.
Both IN pins the same, with ENA on, is a brake: both ends of the motor are tied together, and a spinning motor's own generated current loops round and stops it fast. The datasheet calls it fast motor stop. ENA off opens every switch and the motor coasts: free running motor stop.
The current passes through two switches, and each keeps a little voltage. The L298 datasheet gives 1.8 to 3.2 V lost at 1 A; about 2 V is a working estimate at a small car's currents, so from 7.4 V the motors get about 5.4 V and the 2 V becomes heat in the chip.
In the Troniction car's sketch, F is LOW, HIGH, HIGH, LOW on IN1 to IN4; B is HIGH, LOW, LOW, HIGH; L is HIGH, LOW, HIGH, LOW; R is LOW, HIGH, LOW, HIGH; and S, or any other letter, sets all four HIGH to brake both sides.
The L298N module: every pin, the wiring and a tested sketch →
The L298 datasheet, explained, with the voltage-drop chart →
Common questions
- How does an L298N H-bridge reverse a motor?
- It has four switches around the motor. IN1 and IN2 choose which end of the motor connects to the battery's plus and which to ground. Swap them and the current crosses the motor the other way, so it turns the other way.
- What happens when IN1 and IN2 are both HIGH?
- With ENA on, the motor brakes: both its ends are tied to the same point, and its own generated current stops it fast. Both LOW brakes too. That is different from ENA off, which opens every switch and lets the motor coast.
- Why does the L298N get hot?
- Its switches are transistors that keep about 2 V for themselves at a small car's currents (the datasheet gives 1.8 to 3.2 V at 1 A). That lost voltage times the current is heat in the chip. A stalled motor draws the most current and heats it most.