ABAIN1AIN2BIN1BIN2S16 VS3MS2S4UNO01STEPPERBAAB0101011digitalWrite(AIN1, HIGH);2digitalWrite(AIN2, LOW);3analogWrite(AIN1, 128);10
Back: a battery, the H-bridge (S1-S4) and DC motor inside the DRV8833 outline, and a stepperFront: the Uno's chip, its four input lamps, and the code cardMoving dashes: current; marks on the rotors: which way they turnAn H-bridge: four switches around a DC motor, inside a DRV8833 driver chip, fed by a 6 V battery. Closing S1 and S4 sends current left to right through the motor (forward); S3 and S2 send it right to left (reverse). S1 and S2 together would short the battery. An Arduino Uno chooses the switches through two inputs, and PWM on one input sets the speed. A two-coil stepper turns a step each time the next coil takes current.

Direction: the H-bridge

  1. A DC motor turns one way when current enters its left lead, and the other way when current enters from the right. One transistor, as in the servo and MOSFET lesson, only switches current on and off: one direction.

Driving it from code

Stepper motors

What happens

;; step 1/11 · direction
DC motor   current left -> right : turns forward
           current right -> left : turns in reverse
one transistor: on or off, always the same way round
to reverse, the current must cross the motor the other way

The four switches are drawn as simple switches. Inside the DRV8833 they are N-channel MOSFETs, and its logic only ever selects the four states of its truth table, so it cannot be told to short one side. Its built-in dead time is 450 ns at 5 V. The drawing's rotor is a single two-pole magnet, so 4 steps make a turn. Real hybrid steppers have toothed rotors and stators; 200 steps (1.8°) is common. In the drawing the stepper sits beside the DC motor; really you would connect its coils to the two bridges in place of the motor.