Look up H-bridge. This is a circuit that allows you to reverse polarity to a motor. It requires 4 switches, (MOSFETs or BJTs), If the motor is running off the same voltage as the microntroller, all you need is 2 P-channel and 2 N-channel MOSFETS.
You can also buy chips for this purpose. The...