Page 352 - Lego Mindstorms
P. 352
Robot 10 • RIS Turtle
Writing Your Program
After you have downloaded the NQC program, look through it to get an idea of
how it works. We have indicated where to insert your commands in the main
task. You can try drawing a square first:
Repeat(4)
{
forward(20);
right(90);
}
Try this out and see what happens! If the Turtle moves but does not stop,
you need to adjust the threshold for the light sensor. This is near the beginning
of the program, and we have explained how you should set your threshold
there. (If you are an experienced programmer, you may want to have the Turtle
initialize its own threshold value.) If the Turtle drives backwards when it
should be moving forwards, check that the drive motor is wired correctly. Also,
if the gears shift when the pen should be lowering, you know you have the sec-
ondary motor wired wrong. The orientation of the sensor wires does not matter,
just as long as they are connected to the right port. Once you have the Turtle
working correctly, try to draw some more shapes—you can even get the Turtle
to write your name!
Things to Watch Out For
Over time, the crown gears on the gear shifter will work their way loose. This
can result in poor meshing, and the robot will not drive properly. It is obvious
when this happens because you hear a nasty crunching sound as the gears skip.
Make sure you check periodically that these gears are pressed firmly together.
This is most easily done from the side after removing the wheel. If this happens
often to your robot, you could try to keep the gears on the shaft more firmly by
means of some rubber cement or other removable glue. Whatever method you
try, make sure that the shaft can still rotate freely within the gear shifter piece.
Another problem can arise when the ratchet on the penholder gear jumps.
This sometimes happens when the robot is shifting gears for a turn, and the
pen also lifts a bit. In order to remedy this, you could either extend the axle on
the penholder ratchet to make it heavier or adjust the gear shift sequence in
the program. This would involve starting the secondary motor at a lower power,
and then accelerate up to full power to prevent the jumping.
337