H-bridge: PWM speed, direction and braking
Four switches let current flow through the motor either way. The DRV8833 takes two logic inputs per motor: one high, one low sets the direction; PWM on the high one sets the speed; both high shorts the motor terminals together (brake); both low lets it coast.

Open this lesson in the labFree, in your browser, no account needed.
How it works
analogWrite(…, 128) is a duty of 50.2 %. The motor (6 Ω) sees the average, less the two switches’ 0.36 Ω each: 7.4 × 0.502 × 6 ÷ 6.72 = 3.32 V.
Braking shorts the motor through the low-side switches, so its own generated voltage stops it; coasting leaves it free.
Try it on the bench
- Change the 128 in dutyA to 200: the motor runs faster.
Parts on the bench
- 2 × Bench power supply
- ESP32 DevKit
- USB charger / port
- DRV8833 motor driver
- DC motor
In the course
Electronics Technician, module “Transistor circuits”.