Page 337 - Making things move_ DIY mechanisms for inventors, hobbyists, and artists
P. 337
314 Making Things Move
void down(int distance) {
for(i=0;i< distance; i++){
right_motor.step(-10);
left_motor.step(10);
}
}
void left(int distance) {
for(i=0;i< distance; i++){
right_motor.step(-10);
left_motor.step(-10);
}
}
void right(int distance) {
for(i=0;i< distance; i++){
right_motor.step(10);
left_motor.step(10);
}
}
11. Try covering up the photocells one at a time.
• When you cover the up photocell, the left motor should turn counterclockwise
and the right motor should turn clockwise.
• When you cover the down photocell, the left motor should turn clockwise
and the right motor should turn counterclockwise.
• When you cover the left photocell, both motors should turn
counterclockwise.
• When you cover the right photocell, both motors should turn clockwise.
12. Get out your plywood board and put on your safety glasses. The stepper
motor data sheet from SparkFun indicates that the motor mounting holes are
31mm apart in a square, with the shaft at the center. Make pencil marks up
on the corners of your board where you want the motor shafts to go, and
then measure and make marks at each corner of a 31mm square centered on
that motor shaft mark. Plan your motor mount so it looks like Figure 10-24.