Hardware 26
Hardware
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:
voidsetup(){
}
voidloop(){
motor.run(FORWARD);
motor.setSpeed(125);//halfspeed
delay(1000);//goforwardfor1second
motor.run(RELEASE);
delay(500);//stopforhalfasecond
motor.run(BACKWARD);
motor.setSpeed(255);//fullspeedbackwards
delay(1000);//gobackwardsforasecond
motor.run(RELEASE);
delay(500);//stopforhalfasecond
}
voidloop(){
motor.run(FORWARD); //prepare to go
forward
motor.setSpeed(125); //go around half
speed
delay(1000);//goforwardfor1second
(1000milliseconds
motor.run(RELEASE);//stopthemotor
delay(1000); //stop the motor for 1
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);