Hardware Reference
In-Depth Information
Solution
It would be nice if you could just wire the DC motor to BeagleBone Black and have it
work, but it won't. Most motors require more current than the GPIO ports on the Bone can
supply. Our solution is to use a transistor to control the current to the bone.
Here's what you will need:
▪ 3 V to 5 V DC motor
▪ Breadboard and jumper wires (see “Prototyping Equipment” )
▪ 1 kΩ resistor (see “Resistors” )
▪ Transistor 2N3904 (see “Transistors and Diodes” )
▪ Diode 1N4001 (see “Transistors and Diodes” )
▪ Power supply for the motor (optional)
If you are using a larger motor (more current), you will need to use a larger transistor.
Wire your breadboard as shown in Figure 4-3 .
Figure 4-3. Wiring a DC motor to spin one direction
Use the code in Example 4-2 ( dcMotor.js ) to run the motor.
Example 4-2. Driving a DC motor in one direction (dcMotor.js)
#!/usr/bin/env node
Search WWH ::




Custom Search