Connecting a DC motor and controlling its speed and direction
DC motors are not for precision movement like stepper motors are, but useful for things such as running fans or turning motors where you care more about the speed of the rotation than the accuracy. Using the same L293D chip and the same libraries as the previous chapter, we can control a DC motor's speed and direction.
Getting ready
Instead of a stepper motor, you will want a small DC motor. They are pretty easy to tell apart: a stepper motor has 4 or 5 wires (bipolar stepper motors only have 4, and lack the coil center-tap red wire), and a DC motor only has two. You'll also need an external power source for this one--a 4xAA battery pack is perfect. You can use the same L293D from the previous recipe.
How to do it...
This recipe's schematic is a bit simpler than the previous one, as there is less you have to control with a DC motor.
You'll also add in the AA battery pack:
Controlling the DC motor is similar to controlling LED brightness...