ABC of Electronics cosycom.com
EMBEDDED SYSTEMS & MICROCONTROLLERS · PAGE 33

Controlling Motors

Power from a chip that cannot supply it.

A pin cannot drive a motor directly. Use a transistor or driver chip and a separate power supply sharing ground with the MCU. A diode across the motor absorbs voltage spikes.

PWM sets speed. An H-bridge reverses direction by swapping which side of the motor connects to supply. Servos need a pulse every 20 ms whose width sets the angle.

Stepper motors move in fixed steps, so you can count steps instead of measuring position.