H-bridge
Driving DC motors with digital signals is a common problem, and the h-bridge is designed specifically for that purpose. On the Internet, there are many sites which offer motor driver modules for sale. These are generally built around an H-bridge chip which does the main work.