Download Print this page

Intel Galileo Hardware Manual page 26

Biobots
Hide thumbs Also See for Galileo:

Advertisement

Hardware
void loop(){
forward
speed
(1000 milliseconds
second
Again, test this program to make sure it works.
The last thing we need is to tell the motor to go backwards. We tell the Galileo that we want to go backwards
by typing:
motor.run(BACKWARD);
After telling the Galileo that we want to go backwards, we have to set the speed. Our total program, forward,
stop, back, stop, looks like this:
void setup(){
}
void loop(){
motor.run(FORWARD);
motor.setSpeed(125); //halfspeed
delay(1000); //go forward for 1 second
motor.run(RELEASE);
delay(500); //stop for half a second
motor.run(BACKWARD);
motor.setSpeed(255); //full speed backwards
delay(1000); //go backwards for a second
motor.run(RELEASE);
delay(500); //stop for half a second
}
motor.run(FORWARD); //prepare to go
motor.setSpeed(125); //go around half
delay(1000); //go forward for 1 second
motor.run(RELEASE); //stop the motor
delay(1000); //stop the motor for 1
}
Hardware 26

Advertisement

loading