Galileo code for DC motor direction control
Open the IDE and type in the following code:
This code sets up pins 3
, 4
, and 9
to enable the chip and control the direction of the motor. As mentioned before, you can use the Tools | Serial Port to send data to the program. Sending a 0
sets pin 3 to HIGH and pin 4 to LOW, causing the motor to spin in one direction. Sending a 1
sets pin 3 to LOW and pin 4 to HIGH, causing the motor to spin in the other direction.
Now you know how to build circuits to control both the speed and the direction of DC motors. However, instead of procuring all the parts and building the circuits yourself, you can actually buy a DC motor control shield.