delay(300);
motors.setSpeeds(FORWARD_SPEED, FORWARD_SPEED);
}
else
{
// otherwise, go straight
motors.setSpeeds(FORWARD_SPEED, FORWARD_SPEED);
}
}
You might need to edit a few things in this sketch to make it work well with your Zumo:
• If one or both of your motors have been connected backwards, uncomment lines 53 and/or 54 to correct
their directions.
• If you are using QTR-1A sensors, change line 13 so that
QTR_THRESHOLD
is defined as
QTR_A_THRESHOLD
instead of
QTR_RC_THRESHOLD
, comment line 29, and uncomment line 31.
• Adjust the speeds and durations in lines 17-21. Generally, lower speeds and shorter durations should work
better with faster motors, while higher speeds and longer durations should be more appropriate for slower
motors.
• Finally, the sensor reading thresholds used to differentiate between black and white surfaces, defined in
lines 9 and 10, might need to be changed to suit your environment.
Upload the sketch to an Arduino mounted on a Zumo, place the Zumo on a sumo ring (or a similar large dark
surface with a light border), and press the user pushbutton. Be ready to catch the Zumo in case it drives off
the ring! If everything works right, the Zumo should sound a countdown with its buzzer and then start driving
forward until it detects the ring border; it should then back up, turn, and continue. If not, try adjusting some of the
parameters as described above. Here are some specific troubleshooting tips:
• If the Zumo overshoots the ring border, try lowering
FORWARD_SPEED
(especially if it is going very fast) or
reducing
QTR_RC_THRESHOLD
or
QTR_A_THRESHOLD
(depending on which type of sensor you have).
• If the Zumo stops at the border but turns too much or not enough before continuing, adjust
TURN_SPEED
and/or
TURN_DURATION
.
• If you do not hear any sound from the buzzer, make sure you have the
[http://www.pololu.com/docs/0J57/3.c]
configured correctly for your Arduino.
The ability to wander around while staying inside a sumo ring is enough to allow a Zumo to compete as a basic
sumo robot, but a more advanced robot might be able to detect its opponent and drive toward it directly. As a
next step, you might consider adding more sensors, such as
[http://www.pololu.com/catalog/category/79]
,
to allow the Zumo to find its opponent instead of relying on luck to make contact.
Pololu Zumo Shield for Arduino User's Guide
© 2001–2012 Pololu Corporation
7. Example project: Border-detecting sumo robot
Page 28 of 28