In order to get started with motors using Johnny-Five and the Raspberry Pi, we'll need to add a hat (think Arduino shields, but for the Pi, or add-on boards that stack on the Pi if you're new to electronics) that allows us to:
- Provide external power to the motors
- Control the motors better than the Pi can on its own (especially in the case of the stepper motor)
Wire the battery pack and the motor to the hat's screw terminals like so:
The yellow wire in the diagram should be your ground wire (usually black) and the green should be your power wire (usually red).
Remove all power from the Pi, and make sure the battery pack is switched off. Also, remove the cobbler from the GPIO pins if it is still attached. Then, line up the sockets on the bottom of the hat with the pins on the top of the Pi, in the direction that makes it so the hat is situated over the Pi. Then, gently press down on the hat until...