Using advanced motor control
The previous driving circuits are not suitable for driving motors in more than one direction (as they only switch the motor on or off). However, using a circuit named an H-bridge, you can switch and control the motor's direction, too.
The switch combinations are shown in the following diagram:
The direction of the motor can be controlled by different switch combinations
Using a different combination of switching, we can change the direction of the motor by switching the positive and negative supply to the motor (SW1 and SW4 activate the motor, and SW2 and SW3 reverse the motor). However, not only do we need four switching devices for each motor, but since the ULN2X03 devices and PiBorg's PicoBorg module can only sink current, equivalent devices would be required to source current (to make up the top section of switches).
Fortunately, there are purpose-built H-bridge chips, such as L298N, that contain the previous circuit inside them to provide a powerful and convenient...