So far we have driven motors forward by connecting them to two pins on the Launchpad and setting one pin to HIGH and the other to LOW. We have driven them backwards by setting the pins to LOW and HIGH.
To get more power, we added a transistor, but we lost the ability to reverse the motor, since the transistor can only connect the motor to one side of the power supply.
To get more power, and still be able to reverse the motor, we need a chip called an H-bridge. It has several transistors in it, and they are all connected in a circuit inside the chip, so interfacing the Launchpad and motor to it is very simple. The chip is called the SN754410.
In the photo above, you can see we are only using the left side of the SN754410 chip (pins 1 through 8). The only pin we use on the right side is pin 16, which is what powers the input part of the chip. That part of the chip reads the Launchpad pins, and is powered by the Launchpad's power supply.
The output part of the chip is powered by a separate power supply (in this case a nine volt battery). This is what drives the motor. The output side of the chip can handle a power supply with as much as 36 volts, allowing us to drive some pretty powerful motors.
The state of the SN754410's pin 2 (connected to the Launchpad's Port 1 pin 0) is "copied" to the SN754410's pin 3, but at the higher voltage.
Likewise, input pin 7 is copied to output pin 6, but at the higher voltage.
Here is the program.
In this project, we are running a single motor, so we only need to use the left side of the chip (pins 1 through 8) and pin 9. I chose to use the Launchpad's Port 1 pins 0 and 6 to control the motor since they are connected to the on-board red and green LEDs, and we can see which direction the motor is supposed to spin by looking at the lights.
We could have connected pin 1 of the SN754410 to pin 9, so it would always be enabled. But enabling it in software allows us to power down the chip when we aren't using it, and thus save battery power.
If you want to drive another motor, you use the other side of the SN754410 chip.