Download Print this page

Intel Galileo Hardware Manual page 24

Biobots
Hide thumbs Also See for Galileo:

Advertisement

Hardware
4.4: Controlling a DC Motor
If you are unsure of your wiring, or want to have a test code running, adafruit has example code written,
which should show up in the adafruit-Adafruit-Motor-Shield-library under a file called MotorTest.pde. (Les-
son 4, Figure 3) You can see some of the functions used in running a motor. Running this should cause the
motor to run back and forth repeatedly.
If you want to write your motor program, so you can decide what the motor does, you'll have to go through
some steps.
The first thing you'll need to do to control a motor is to include the library. At the beginning of your program,
setup
before void
, you have to write:
#include <AFMotor.h>
This tells the Galileo that you are using the Adafruit Motor library, so it knows what the functions you are us-
ing are. This will save you from having to write your own functions.
Then you have to tell the Galileo the name of your motor, and where it is connected:
AF_DCMotor mymotor(1);
Lesson 4, Figure 3
Hardware 24

Advertisement

loading